Query Probes


The query-start and query-done probes are triggered when a specific query is received by the server and when the query has been completed and the information has been successfully sent to the client.

query-start(query, connectionid, database, user, host)
query-done(status)

You can get a simple report of the execution time for each query using the following D script:

#!/usr/sbin/dtrace -s
#pragma D option quiet dtrace:::BEGIN
{
 printf('%-20s %-20s %-40s %-9s\n', 'Who', 'Database', 'Query', 'Time(ms)');
}
mysql*:::query-start
{
 self->query = copyinstr(arg0);
 self->connid = arg1;
 self->db = copyinstr(arg2);
 self->who = strjoin(copyinstr(arg3),strjoin('@',copyinstr(arg4)));
 self->querystart = timestamp;
}
mysql*:::query-done
{
 printf('%-20s %-20s %-40s %-9d\n',self->who,self->db,self->query,
 (timestamp - self->querystart) / 1000000);
}

When executing the above script you should get a basic idea of the execution time of your queries:

Retornar