1. 简介
是什么:是mysql提供可以用来分析当前会话中语句执行的资源消耗情况。可以用于SQL的调优的测量.
http://dev.mysql.com/doc/refman/5.5/en/show-profile.html
默认情况下,参数处于关闭状态,并保存最近15次的运行结果
2. 查询是否开启该功能
show variables like 'profiling;
默认是关闭,使用前需要开启
3. 默认是关闭的,执行下面命令打开:
set profiling=1;
查看结果:
诊断SQL,show profile cpu,block io for query n (n为上一步前面的问题SQL数字号码);
另外说明一下这个show profile语句:
show profile cpu, block io, memory,swaps,context switches,source for query [Query_ID];
# Show profile后面的一些参数:
# - All:显示所有的开销信息
# - Cpu:显示cpu相关开销
# - Block io:显示块IO相关开销
# - Context switches: 上下文切换相关开销
# - Memory:显示内存相关开销
# - Source:显示和source_function,source_file,source_line相关的开销信息