Slow Query Log containing Profiling results

83 views Asked by At

I'm using MySQL/InooDB. Currently slow query log is enabled on my server.

I want to see profiling result of a specific slow query when it executed. I know how to do profiling, but for me it's not much useful to do it after a query is logged as slow, because it always run very faster. Maybe the server load or another stress on server made that query slow and I need to know the reason.

Something like this:

# Query_time: 5.045559  Lock_time: 0.000021 Rows_sent: 1  Rows_examined: 1
SET timestamp=1481983357;
SELECT id FROM Table WHERE id=125;
+----------------------+----------+
| Status               | Duration |
+----------------------+----------+
| starting             | 0.000156 |
| checking permissions | 0.000014 |
| Opening tables       | 0.000034 |
| System lock          | 0.000025 |
| init                 | 0.000035 |
| optimizing           | 0.000009 |
| statistics           | 0.000067 |
| preparing            | 0.000005 |
| executing            | 0.000064 |
| end                  | 0.000006 |
| query end            | 0.000005 |
| closing tables       | 0.000008 |
| freeing items        | 0.000013 |
| logging slow query   | 0.000002 |
| cleaning up          | 0.000002 |
+----------------------+----------+
15 rows in set (0.00 sec)

Is there any way to do it?

0

There are 0 answers