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

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 |
+----------------------+----------+-------+-------+--------------+

转载于:https://www.cnblogs.com/lehao/p/3928832.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值