I was recently helping some colleagues check what was happening with their MySQL queries, and wrote a DTrace script to do it. Time to share that script.
First of all, a look at some output from the script:
mashie[bash]# ./querystat.d -p `pgrep mysqld` Tracing started at 2009 Sep 17 16:28:35 2009 Sep 17 16:28:38 throughput 3 queries/sec 2009 Sep 17 16:28:41 throughput 4 queries/sec 2009 Sep 17 16:28:44 throughput 528 queries/sec 2009 Sep 17 16:28:47 throughput 1603 queries/sec 2009 Sep 17 16:28:50 throughput 1676 queries/sec ^C Tracing ended at 2009 Sep 17 16:28:51 Average latency, all queries: 107 us Latency distribution, all queries (us): value ------------- Distribution ------------- count 16 | 0 32 |@@ 170 64 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ … |