MySQL性能分析语句 show profile/show profiles
2017-11-27 16:04
791 查看
转载自 http://blog.csdn.net/littleboyandgirl/article/details/68486642
功能说明
show profile 和 show profiles 语句可以展示当前会话(退出session后,profiling重置为0) 中执行语句的资源使用情况.
Profiling 功能由MySQL会话变量 : profiling控制,默认是OFF.关闭状态.
select @@profiling;
show variables like ‘%profil%’;
通过以上两个语句均可以查看 当前session是否打开了profile功能.
Profiling 信息收集依赖于调用 系统方法 getrusage().因此Windows系统不适用.
另外Profiling是针对进程(process)而非线程(threads),因此运行在服务器上的其他服务进程可能会影响分析结果.
语句使用
show profiles :列表,显示最近发送到服务器上执行的语句的资源使用情况.显示的记录数由变量:profiling_history_size 控制,默认15条.
show profile: 展示最近一条语句执行的详细资源占用信息,默认显示 Status和Duration两列.
show profile 还可根据 show profiles 列表中的 Query_ID ,选择显示某条记录的性能分析信息.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
举例
查看是否打开了性能分析功能
打开 profiling 功能
执行sql语句
执行 show profiles 查看分析列表
查询第二条语句的执行情况
可指定资源类型查询
功能说明
show profile 和 show profiles 语句可以展示当前会话(退出session后,profiling重置为0) 中执行语句的资源使用情况.
Profiling 功能由MySQL会话变量 : profiling控制,默认是OFF.关闭状态.
select @@profiling;
show variables like ‘%profil%’;
通过以上两个语句均可以查看 当前session是否打开了profile功能.
Profiling 信息收集依赖于调用 系统方法 getrusage().因此Windows系统不适用.
另外Profiling是针对进程(process)而非线程(threads),因此运行在服务器上的其他服务进程可能会影响分析结果.
语句使用
show profiles :列表,显示最近发送到服务器上执行的语句的资源使用情况.显示的记录数由变量:profiling_history_size 控制,默认15条.
show profile: 展示最近一条语句执行的详细资源占用信息,默认显示 Status和Duration两列.
show profile 还可根据 show profiles 列表中的 Query_ID ,选择显示某条记录的性能分析信息.
语法结构: SHOW PROFILE [type [, type] ... ] [FOR QUERY n] [LIMIT row_count [OFFSET offset]] type: ALL | BLOCK IO | CONTEXT SWITCHES | CPU | IPC | MEMORY | PAGE FAULTS | SOURCE | SWAPS1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
举例
查看是否打开了性能分析功能
select @@profiling;1
打开 profiling 功能
set profiling=1;1
执行sql语句
执行 show profiles 查看分析列表
查询第二条语句的执行情况
show profile for query 2;1
可指定资源类型查询
show profile cpu,swaps for query 2;
相关文章推荐
- MySQL性能分析语句 show profile/show profiles
- MySQL性能分析语句 show profile/show profiles
- mysql show profiles 使用分析sql 性能
- mysql show profiles 使用分析sql 性能
- mysql 分析3使用分析sql 性能 show profiles ;
- mysql show profiles 使用分析sql 性能
- MySql性能分析工具之Show Profile
- mysql 分析3使用分析sql 性能 show profiles ;
- mysql show profiles 使用分析sql 性能
- mysql show profiles 使用分析sql 性能
- mysql show profiles使用分析sql性能
- mysql show profiles 查看sql语句性能
- MYSQL性能分析之show profiles
- mysql使用profile分析语句性能消耗
- 使用show profiles分析查询语句性能
- mysql show profiles 使用分析sql 性能
- MYSQL sql 语句性能分析
- mysql show profiles使用分析sql性能
- MySQL PROFILE 跟踪语句各阶段性能开销
- show profiles 查看MySQL语句的执行时间