//开启
set profiling=1;
//切换数据库
use mysql;
//显示表列表
show tables;
//查看已缓存的sql
show profiles;
+----------+------------+-----------------------------+
| Query_ID | Duration | Query |
+----------+------------+-----------------------------+
| 1 | 0.00008025 | show tablses |
| 2 | 0.00070700 | show tables |
| 3 | 0.00106750 | SELECT * FROM `server_cost` |
| 4 | 0.00065550 | show tables |
+----------+------------+-----------------------------+
//显示查询耗时分布情况
show profile for query 3;
+----------------------+----------+
| Status |Duration(s)|
+----------------------+----------+
| starting | 0.000070 |
| checking permissions | 0.000006 |
| Opening tables | 0.000809 |
| init | 0.000018 |
| System lock | 0.000007 |
| optimizing | 0.000003 |
| statistics | 0.000018 |
| preparing | 0.000010 |
| executing | 0.000005 |
| Sending data | 0.000060 |
| end | 0.000004 |
| query end | 0.000005 |
| closing tables | 0.000005 |
| freeing items | 0.000035 |
| cleaning up | 0.000015 |
+----------------------+----------+