MYSQ--SHOW PROFILE Syntax and useing
原创
©著作权归作者所有:来自51CTO博客作者woxuewangluo的原创作品,请联系作者获取转载授权,否则将追究法律责任
The SHOW PROFILE
and SHOW PROFILES
statements display profiling information that indicates resource usage for statements executed during the course of the current session. 1、开启PROFILE(这对会话开启):
Profiling is controlled by the profiling
session variable, which has a default value of 0 (OFF
). Profiling is enabled by setting profiling
to 1 or ON
: mysql> select @@profiling;
+-------------+
| @@profiling |
+-------------+
| 0 |
+-------------+
1 row in set (0.00 sec)
mysql> set profiling=1;
Query OK, 0 rows affected (0.00 sec)
2、查看开启情况:
mysql> select @@profiling;
+-------------+
| @@profiling |
+-------------+
| 1 |
+-------------+
1 row in set (0.00 sec)
3、做几次查下,然后用show profiles查看:
mysql> show profiles;
+----------+------------+------------------+
| Query_ID | Duration | Query |
+----------+------------+------------------+
| 1 | 0.01432675 | select * from c |
| 2 | 0.00025350 | select * from c |
+----------+------------+------------------+
显示的是当前会话的执行的最近的sql语句,查询的默认记录值是15条,最大值是100.
mysql> show profile all for query 2;