[mysql] 查看mysql执行时间

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)

  

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。