查看一条mysql语句的性能

mysql数据库在5.0.37版本后添加了Show profiles功能,可以分析出一条sql语句的性能。

检查数据库是否支持Show profiles功能:show variables like "%version%";

查看profiles是否开启:show variables like "%pro%";

开启命令:set profiling = 1;

执行sql语句:

执行 show profile;查看执行的各个语句。

比如说查看第10条语句:select username,password from users where adduser = 'js' 每一个环节的时间:

命令是:show profile for query 10;

分析结束后set profiling = 0;  关闭Show profiles功能。

原文地址:https://www.cnblogs.com/jhxshell/p/12891946.html