mysql的 profiling不是默认打开的
查看profiling是否找开
mysql> show variables like "%pro%";
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| profiling | OFF |
| profiling_history_size | 15 |
| protocol_version | 10 |
| slave_compressed_protocol | OFF |
+---------------------------+-------+
打开profiling
mysql> set profiling=1;
使用
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| test |
| user |
+----------------+
mysql> select * from test;
mysql> show profiles;
+----------+------------+------------------------+
| Query_ID | Duration | Query |
+----------+------------+------------------------+
| 1 | 0.00054675 | show tables |
| 2 | 0.00032400 | select * from test |
+----------+------------+------------------------+
2 rows in set (0.00 sec)
mysql> show profile for query 1;
+----------------------+-----------+
| Status | Duration |
+----------------------+-----------+
| (initialization) | 0.000028 |
| checking permissions | 0.000007 |
| Opening tables | 0.0000939 |
| System lock | 0.0000017 |
| Table lock | 0.0000055 |
| init | 0.000009 |
| optimizing | 0.0000027 |
| statistics | 0.0000085 |
| preparing | 0.0000065 |
| executing | 0.000004 |
| checking permissions | 0.000258 |
| Sending data | 0.000049 |
| end | 0.0000037 |
| query end | 0.0000027 |
| freeing items | 0.0000307 |
| closing tables | 0.0000032 |
| removing tmp table | 0.0000275 |
| closing tables | 0.0000037 |
| logging slow query | 0.000002 |
+----------------------+-----------+
19 rows in set (0.00 sec)