mysql profiling表_Mysql-性能分析(profiling 工具)

Mysql-性能分析(profiling 工具)

说明

profiling 工具可以用来查看sql语句的执行时间,可以用来查看sql语句的详细执行过程

基本命令 1.查看profiling的开启情况,默认是不开启的,值是0,开启之后值是1。

select @@profiling;

2.启动profiling:

set @@profiling=1

3.关闭profiling

set @@profiling=0;

4.查看sql语句的执行时间

show profiles;

5.查看某个查询语句的详细过程

show profile for query 1;

使用示例

查看语句执行时间 mysql> select count(*) from user;

+----------+

| count(*) |

+----------+

| 88 |

+----------+

1 row in set (0.00 sec)

mysql> select count(1) from user;

+----------+

| count(1) |

+----------+

| 88 |

+----------+

1 row in set (0.00 sec)

mysql> show profiles;

+----------+------------+---------------------------+

| Query_ID | Duration | Query |

+----------+------------+---------------------------+

| 1 | 0.00023950 | select count(*) from user |

| 2 | 0.00024500 | select count(1) from user |

+----------+------------+---------------------------+

2 rows in set, 1 warning (0.01 sec)

查看某个语句详细过程 mysql> show profile for query 1;

+----------------------+----------+

| Status | Duration |

+----------------------+----------+

| starting | 0.000075 |

| checking permissions | 0.000006 |

| Opening tables | 0.000020 |

| init | 0.000014 |

| System lock | 0.000006 |

| optimizing | 0.000006 |

| statistics | 0.000015 |

| preparing | 0.000010 |

| executing | 0.000002 |

| Sending data | 0.000051 |

| end | 0.000004 |

| query end | 0.000007 |

| closing tables | 0.000007 |

| freeing items | 0.000008 |

| cleaning up | 0.000009 |

+----------------------+----------+

15 rows in set, 1 warning (0.00 sec)

结尾

这一个黑夜的孩子,沉浸于冬天,倾心死亡不能自拔,热爱着空虚而寒冷的乡村--《春天,十个海子》

本文由 张六六柒 创作,采用 知识共享署名4.0 国际许可协议进行许可

本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名

最后编辑时间为: Feb 14, 2020 at 03:58 am

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值