Query Parsing Probes


The query parsing probes are triggered before the original SQL statement is parsed and when the parsing of the statement and determination of the execution model required to process the statement has been completed:

query-parse-start(query)
query-parse-done(status)

For example, you could monitor the execution time for parsing a given query using the following D script:

#!/usr/sbin/dtrace -s
#pragma D option quiet mysql*:::query-parse-start
{
 self->parsestart = timestamp;
 self->parsequery = copyinstr(arg0);
}
mysql*:::query-parse-done
/arg0 == 0/
{
 printf('Parsing %s: %d microseconds\n', self->parsequery,((timestamp - self->parsestart)/1000));
}
mysql*:::query-parse-done
/arg0 != 0/
{
 printf('Error parsing %s: %d microseconds\n', self->parsequery,((timestamp - self->parsestart)/1000));
}

In the above script a predicate is used on query-parse-done so that different output is generated based on the status value of the probe.

When running the script and monitoring the execution:

Retornar