1.查看 profiling 是否开启:

show variables like 'profiling';

2.默认关闭,开启

set profiling=on;

4.查看执行过的语句

show profiles;

mysql--show Profile 分析--全局查询日志

5.选择一个 QueryID 进行下一步查询:

show profile cpu,block io for query 4;
 

 

mysql--show Profile 分析--全局查询日志

可以根据上面的内容进行分析:

当出现下面的 状态时 必须进行优化:

mysql--show Profile 分析--全局查询日志

group by 容易创建临时表 ;

 

全局查询日志:

这个功能推荐在测试中使用,开发中设置为off;

下面介绍使用:

1.开启,设置 日志显示方式为表格

set global general_log =1;

set global log_output='TABLE';

2.查看日志


select argument from mysql.general_log;
 

 

相关文章: