mysql> show profiles; +----------+---------+----------------------------------------------------------------------------------+ | Query_ID | Time | Query | +----------+---------+----------------------------------------------------------------------------------+ | 1 | 19021 | show databases | | 3 | 5 | show tables | | 4 | 5 | | | 5 | 6 | | | 6 | 5 | | | 8 | 355512 | select * from test.a | | 11 | 1867039 | select sum(nr) from (select sub, count(*) as nr from sclot__a group by sub) as a | | 14 | 1484977 | select sum(nr) from (select sub, count(*) as nr from sclot__a group by sub) as a | | 17 | 1502227 | select sum(nr) from (select sub, count(*) as nr from sclot__a group by sub) as a | | 18 | 1485255 | select sum(nr) from (select sub, count(*) as nr from sclot__a group by sub) as a | +----------+---------+----------------------------------------------------------------------------------+ 10 rows in set (0.00 sec) mysql> show profile for query 11; +--------------------------+--------------+ | Status | Time_elapsed | +--------------------------+--------------+ | Opening tables | 346763 | | System lock | 346829 | | Table lock | 346843 | | optimizing | 358729 | | statistics | 358755 | | preparing | 358794 | | creating temporary table | 358850 | | executing | 358994 | | Copying to tmp table | 359006 | | Sorting result | 1836636 | | Sending data | 1842659 | | removing tmp table | 1853262 | | Sending data | 1856454 | | init | 1856497 | | optimizing | 1856629 | | statistics | 1856674 | | preparing | 1856711 | | executing | 1856738 | | Sending data | 1856775 | | cleaning up | 1865450 | | end | 1865473 | | query end | 1865481 | | freeing items | 1865491 | | closing tables | 1865634 | | removing tmp table | 1865642 | | closing tables | 1866670 | | cleaning up | 1867039 | +--------------------------+--------------+ 27 rows in set (0.00 sec) mysql> show profile cpu, block io for query 11; +--------------------------+--------------+----------+------------+--------------+---------------+ | Status | Time_elapsed | CPU_user | CPU_system | Block_ops_in | Block_ops_out | +--------------------------+--------------+----------+------------+--------------+---------------+ | Opening tables | 346763 | 328 | 959 | 0 | 2 | | System lock | 346829 | 377 | 970 | 0 | 2 | | Table lock | 346843 | 387 | 974 | 0 | 2 | | optimizing | 358729 | 687 | 1239 | 0 | 2 | | statistics | 358755 | 699 | 1253 | 0 | 2 | | preparing | 358794 | 735 | 1256 | 0 | 2 | | creating temporary table | 358850 | 764 | 1283 | 0 | 2 | | executing | 358994 | 885 | 1306 | 0 | 2 | | Copying to tmp table | 359006 | 889 | 1313 | 0 | 2 | | Sorting result | 1836636 | 1046514 | 342413 | 0 | 2 | | Sending data | 1842659 | 1051339 | 343185 | 0 | 2 | | removing tmp table | 1853262 | 1060830 | 344179 | 0 | 2 | | Sending data | 1856454 | 1063675 | 344502 | 0 | 2 | | init | 1856497 | 1063701 | 344518 | 0 | 2 | | optimizing | 1856629 | 1063778 | 344573 | 0 | 2 | | statistics | 1856674 | 1063796 | 344601 | 0 | 2 | | preparing | 1856711 | 1063829 | 344604 | 0 | 2 | | executing | 1856738 | 1063853 | 344607 | 0 | 2 | | Sending data | 1856775 | 1063887 | 344610 | 0 | 2 | | cleaning up | 1865450 | 1069762 | 344887 | 0 | 2 | | end | 1865473 | 1069774 | 344897 | 0 | 2 | | query end | 1865481 | 1069779 | 344900 | 0 | 2 | | freeing items | 1865491 | 1069787 | 344903 | 0 | 2 | | closing tables | 1865634 | 1069857 | 344976 | 0 | 2 | | removing tmp table | 1865642 | 1069861 | 344980 | 0 | 2 | | closing tables | 1866670 | 1070672 | 345178 | 0 | 2 | | cleaning up | 1867039 | 1070924 | 345294 | 0 | 2 | +--------------------------+--------------+----------+------------+--------------+---------------+ 27 rows in set (0.00 sec) mysql> show profile source for query 8; +----------------+--------------+-----------------------+---------------+-------------+ | Status | Time_elapsed | Source_function | Source_file | Source_line | +----------------+--------------+-----------------------+---------------+-------------+ | Opening tables | 2657 | open_tables | sql_base.cc | 1953 | | System lock | 2720 | mysql_lock_tables | lock.cc | 148 | | Table lock | 2758 | mysql_lock_tables | lock.cc | 155 | | init | 2784 | mysql_select | sql_select.cc | 1837 | | optimizing | 2845 | optimize | sql_select.cc | 543 | | statistics | 2857 | optimize | sql_select.cc | 655 | | preparing | 2893 | optimize | sql_select.cc | 665 | | executing | 2917 | exec | sql_select.cc | 1188 | | Sending data | 2925 | exec | sql_select.cc | 1693 | | cleaning up | 355371 | mysql_select | sql_select.cc | 1882 | | end | 355396 | mysql_select | sql_select.cc | 1884 | | query end | 355405 | mysql_execute_command | sql_parse.cc | 4796 | | freeing items | 355416 | mysql_parse | sql_parse.cc | 5595 | | closing tables | 355491 | dispatch_command | sql_parse.cc | 2042 | | cleaning up | 355512 | dispatch_command | sql_parse.cc | 2065 | +----------------+--------------+-----------------------+---------------+-------------+ 15 rows in set (0.00 sec)