MySQL性能分析语句 show profile/show profiles
功能说明
- show profile 和 show profiles 语句可以展示当前会话(退出session后,profiling重置为0) 中执行语句的资源使用情况.
例一、
1、查看是否打开了性能分析功能
select @@profiling;
2、打开 profiling 功能
set profiling=1;
3、执行sql语句
4、执行 show profiles 查看分析列表
5、查询第二条语句的执行情况
show profile for query 2;
6、可指定资源类型查询
show profile cpu,swaps for query 2;
例二、
不用索引的,虽然检索的行数多,但是直接访问表数据快
时间差一个单位