mysql profiles清空_Mysql内置优化工具show profiles

一、概述:

Mysql的explain工具目前还没有Oracle的explain plan工具那么强大,但是结合show profiles工具可以实现相似的效果。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

二、开启profiling

show variables like '%profil%';

1e082ce4d8e0221d

set @@session.profiling=1; --会话级别开启

1e082ce4d8e0221d

show profiles在Mysql5.6.7之后官方已经不推荐继续使用(deprecated),转而支持performance_schema(感觉老麻烦,还是show profile简单),performance_schema用法详见如下链接:

https://dev.mysql.com/doc/refman/5.6/en/performance-schema-query-profiling.html

三、show profiles的使用

废话不多说,直接3张图说明。(注意:单个query查询用的是show profile不是show profiles)

1e082ce4d8e0221d

1e082ce4d8e0221d

1e082ce4d8e0221d

至于图中各个列的解释,官网说明在此:(即infomation_schema.PROFILING表的说明)

QUERY_ID is a numeric statement identifier.

SEQ is a sequence number indicating the display order for rows with the same QUERY_ID value.

STATE is the profiling state to which the row measurements apply.

DURATION indicates how long statement execution remained in the given state, in seconds.

CPU_USER and CPU_SYSTEM indicate user and system CPU use, in seconds.

CONTEXT_VOLUNTARY and CONTEXT_INVOLUNTARY indicate how many voluntary and involuntary context switches occurred.

BLOCK_OPS_IN and BLOCK_OPS_OUT indicate the number of block input and output operations.

MESSAGES_SENT and MESSAGES_RECEIVED indicate the number of communication messages sent and received.

PAGE_FAULTS_MAJOR and PAGE_FAULTS_MINOR indicate the number of major and minor page faults.

SWAPS indicates how many swaps occurred.

SOURCE_FUNCTION, SOURCE_FILE, and SOURCE_LINE provide information indicating where in the source code the profiled state executes.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值