Mysql 开启profile
select @@profiling; 查看是否开启(0-未开启,1-已开启)
set profiling = 1; 开启该配置。开启后不用关,一段时间后会自动关闭。开启后就可以执行sql了
show profiles; 展示执行的sql
show profile for query 97; 查看指定执行sql信息
show profile all for query 1; 查看指定执行sql所有信息
Mysql profile 执行结果
Status: updating
Duration: 14.288116
CPU_user: 25.124942 当前用户占有的 cpu
CPU_system: 0.638677 系统占有的 cpu
Context_voluntary: 3755
Context_involuntary: 236
Block_ops_in: 736 I/O 输入
Block_ops_out: 54176 I/O 输出
Messages_sent: 0
Messages_received: 0
Page_faults_major: 0
Page_faults_minor: 12429
Swaps: 0
Source_function: mysql_update
Source_file: sql_update.cc
Source_line: 791
结果信息:
"Status": "query end", 状态
"Duration": "1.751142", 持续时间
"CPU_user": "0.008999", cpu用户
"CPU_system": "0.003999", cpu系统
"Context_voluntary": "98", 上下文主动切换
"Context_involuntary": "0", 上下文被动切换
"Block_ops_in": "8", 阻塞的输入操作
"Block_ops_out": "32", 阻塞的输出操作
"Messages_sent": "0", 消息发出
"Messages_received": "0", 消息接受
"Page_faults_major": "0", 主分页错误
"Page_faults_minor": "0", 次分页错误
"Swaps": "0", 交换次数
"Source_function": "mysql_execute_command", 源功能
"Source_file": "sql_parse.cc", 源文件
"Source_line": "4465" 源代码行