SHOW PROFILES command and its profiling support is something that I can’t believe I hadn’t spotted before today.
It allows you to enable profiling for a session and then record performance information about the queries executed. It shows details of the different stages in the query execution (as usually displayed in the thread state output of
SHOW PROCESSLIST) and how long each of these stages took.
I’ll demonstrate using an example. First within our session we need to enable profiling, you should only do this in sessions that you want to profile as there’s some overhead in performing/recording the profiling information:
mysql> SET profiling=1; Query OK, 0 rows affected (0.00 sec)
Now let’s run a couple of regular SELECT queries
mysql> SELECT[Read more...]