Every wounder what was taking MySQL so long to run your query. You can ask it.
mysql > set profiling=1;
mysql> SELECT * FROM country WHERE city like ‘okla’ order by name;
mysql> SHOW PROFILES;
You should now see a table with a single row, with the number 1 to the left of your query.
mysql> SHOW PROFILE FOR QUERY 1;
There is more and you can read about it at
You’ll see a table summarizing how long each stage of executing the query took:
+--------------------------------+----------+ | Status | Duration | +--------------------------------+----------+ | starting | 0.000050 | | checking query cache for query | 0.000102 | | Opening tables | 0.018733 | | System lock | 0.000010 | | Table lock | 0.000006 | | init | 0.007367 | | optimizing | 0.000004 | | statistics | 0.000006 | | preparing | 0.000005 | | executing | 0.000002 | | Sorting result | 0.027435 | | Sending data | 0.000023 | | end | 0.000002 | | query end | 0.000002 | | freeing items | 0.000031 | | logging slow query | 0.000002 | | cleaning up | 0.000001 | +--------------------------------+----------+ 16 rows in set (0.00 sec)
To turn profiling off
mysql> set profiling=0;
There is more and you can read about it at http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.htm.
Tweet