PROFILE 可以跟踪查询语句各个阶段 Time,IO,CPU,MEMORY 等资源使用情况,比较详细。所以系统一般不会记录太多。启用是全局的,所以每个连接都保持语句的资源使用情况。
The SHOW PROFILE and SHOW PROFILES statements display profiling information that indicates resource usage for statements executed during the course of the current session.
mysql> select @@profiling;
mysql> show variables like '%profiling%';
mysql> set profiling = 1;
mysql> set profiling_history_size = 10;
mysql> show profiles;
SHOW PROFILE [type [, type] ... ]
[FOR QUERY n]
[LIMIT row_count [OFFSET offset]]
type:
ALL
| BLOCK IO
| CONTEXT SWITCHES
| CPU
| IPC
| MEMORY
| PAGE FAULTS
| SOURCE
| SWAPS
默认显示时间信息,显示了该查询从开始到被清除各个阶段的执行时间。
mysql> show profile;
其他查看方法:
mysql> show profile; #默认显示时间信息
mysql> show profile CPU,BLOCK IO; #(时间)加上 CPU,BLOCK IO 使用情况
mysql> show profile for query 6; #query_id=6的(时间)信息
mysql> show profile CPU for query 6; #query_id=6的cpu信息
mysql> show profile CPU limit 6; #前6个状态信息(前6行)
mysql> show profile CPU limit 6 offset 2;#第2行起前6个状态信息(前2~7行)
set profiling = 0;
set profiling_history_size = 0;
后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下!
留言与评论(共有 0 条评论) |