开启show profile 查看sql执行周期
修改配置文件 /etc/my.cnf
新增一行: query_cache_type = 1;
重启mysql
先开启,然后看看 show variables like ‘%profiling%’;
set profiliing = 1;
执行一些sql语句
show profiles ;显示最近几次查询
1 是否支持,看看当前mysql 版本是否支持
2 开启功能,默认是关闭,使用前需要开启
show variables like 'profiling';
4 show profiles
5诊断sql 输入 show profile cpu,block io for query 3 其中3是id ,结合上图查看
其中 show profile 的语句 type 包括 以下几种
出现这4种都是很头疼的事情,出现这4个其中一种,则必须优化