Mysql之Show profile

一、Show Profile是什么?

    是MySql提供可以用来分析当前会话中语句执行的资源消耗情况,可以用于SQL的调优的测量。

    默认情况下,参数处于关闭状态,并保存最近15次的运行结果。
二、分析步骤
1.开启功能,默认是关闭,使用前需要开启。

Mysql之Show profile

3、运行SQL select * from emp group by id%20 order by 5;
4、查看结果,show profiles

Mysql之Show profile

5、诊断SQL,show profile cpu,block io for query 上一步前面的问题SQL数字号码;

Mysql之Show profile

Mysql之Show profile

6、日常开发需要注意的结论
Converting HEAP to MyISAM查询结果太大,内存不够用往磁盘上搬。
Creating tmp table 创建临时表
Coping to tmp on disk 把内存中临时表复制到磁盘,危险!!

 Mysql之Show profile