Mysql内置优化工具show profiles
一、概述:
Mysql的explain工具目前還沒有Oracle的explain plan工具那么強(qiáng)大,但是結(jié)合show profiles工具可以實(shí)現(xiàn)相似的效果。show profiles語句用于在當(dāng)前會(huì)話執(zhí)行的語句的資源使用情況。其具體語法為:
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%';set @@session.profiling=1; --會(huì)話級(jí)別開啟
show profiles在Mysql5.6.7之后官方已經(jīng)不推薦繼續(xù)使用(deprecated),轉(zhuǎn)而支持performance_schema(感覺老麻煩,還是show profile簡(jiǎn)單),performance_schema用法詳見如下鏈接:
https://dev.mysql.com/doc/refman/5.6/en/performance-schema-query-profiling.html
三、show profiles的使用
廢話不多說,直接3張圖說明。(注意:單個(gè)query查詢用的是show profile不是show profiles)
至于圖中各個(gè)列的解釋,官網(wǎng)說明在此:(即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.轉(zhuǎn)載于:https://www.cnblogs.com/leohahah/p/8385528.html
總結(jié)
以上是生活随笔為你收集整理的Mysql内置优化工具show profiles的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ldconfig与 /etc/ld.so
- 下一篇: 监听Activity的生命周期的方式。