首页 > 其他 > 详细

分析语句执行步骤并对排出耗时比较多的语句

时间:2014-08-22 12:17:46      阅读:240      评论:0      收藏:0      [点我收藏+]

mysql>set profiling=1;

mysql>show profiles;
mysql> set @query_id=6;
Query OK, 0 rows affected (0.00 sec)

mysql> select state,sum(duration) as total_R,round(100*sum(duration)/(select sum(duration) from information_schema.profiling where query_id=@query_id),2) as Pct_R,count(*) as Calls,sum(DURATION)/count(*) as "R/Call" from information_schema.profiling where query_id=@query_id group by state order by Total_R DESC;
+----------------------+----------+-------+-------+--------------+
| state | total_R | Pct_R | Calls | R/Call |
+----------------------+----------+-------+-------+--------------+
| Sending data | 0.026548 | 44.76 | 1 | 0.0265480000 |
| init | 0.025457 | 42.92 | 1 | 0.0254570000 |
| System lock | 0.005633 | 9.50 | 1 | 0.0056330000 |
| query end | 0.001312 | 2.21 | 1 | 0.0013120000 |
| freeing items | 0.000155 | 0.26 | 1 | 0.0001550000 |
| starting | 0.000076 | 0.13 | 1 | 0.0000760000 |
| Opening tables | 0.000029 | 0.05 | 1 | 0.0000290000 |
| statistics | 0.000019 | 0.03 | 1 | 0.0000190000 |
| cleaning up | 0.000019 | 0.03 | 1 | 0.0000190000 |
| closing tables | 0.000017 | 0.03 | 1 | 0.0000170000 |
| end | 0.000015 | 0.03 | 1 | 0.0000150000 |
| preparing | 0.000012 | 0.02 | 1 | 0.0000120000 |
| optimizing | 0.000011 | 0.02 | 1 | 0.0000110000 |
| checking permissions | 0.000011 | 0.02 | 1 | 0.0000110000 |
| executing | 0.000002 | 0.00 | 1 | 0.0000020000 |
+----------------------+----------+-------+-------+--------------+

分析语句执行步骤并对排出耗时比较多的语句,布布扣,bubuko.com

分析语句执行步骤并对排出耗时比较多的语句

原文:http://www.cnblogs.com/lehao/p/3928832.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!