1. 查看是否开启 show variables like 'profiling'; 2. 开启功能 set profiling = on 3. 运行sql #写的尽量耗时的sql,利于分析 select * from xxx group by id%20 order by 5; #show profile 会记录这条sql 4. 查询结果 show profiles 5. 诊断sql #cpu,block io 常用的两个参数 show profile cpu,block io for que…