show profiles 使用分析sql性能

Show profiles是5.0.37之后添加的,要想使用此功能,要确保版本在5.0.37之后。

查看一下我的数据库版本

show profiles 使用分析sql性能

版本是支持show profiles功能的。接下来进入mysql性能跟踪诊断的世界

查看是否打开了profiles功能,默认是关闭的

show profiles 使用分析sql性能

显示为空,说明profiles功能是关闭的。下面开启

show profiles 使用分析sql性能

执行几行查询,然后执行show profiles

show profiles 使用分析sql性能

可以看到命令执行时间,根据query_id 查看某个查询的详细时间耗费

show profiles 使用分析sql性能

还可以查看占用cpu、 io等信息

show profiles 使用分析sql性能

 

转载于:https://my.oschina.net/jzgycq/blog/1595465