mysql性能監(jiān)控和sql語句

1、查詢緩存:

  mysql> show variables like '%query_cache%';

2、緩存在Cache中線程數(shù)量thread_cache_size:

  mysql> show variables like 'thread%';

3、DB已連接的線程數(shù):

  mysql> show status like 'connections';

4、當(dāng)前連接線程狀態(tài):

  mysql> show status like '%thread%';

5、索引緩存大小:

  mysql> show variables like 'key_buffer_size';

6、索引緩存未命中率:

  mysql> show global status like 'key_read%';

7、索引緩存命中率:

  mysql> show global status like 'key_%';

8、索引讀取統(tǒng)計(jì):

  mysql> show global status like 'key_blocks_u';

  key_blocks_unused表示未使用的緩存簇(blocks)數(shù),key_blocks_used表示曾經(jīng)用到的最大的blocks,如果緩存都用到了,要么增加key_buffer_size,要么過度索引,把緩存占滿了。

9、并發(fā)最大連接數(shù)-允許最大連接數(shù)(一般500到800比較合適):

  mysql> show variables like 'max_connections';

10、并發(fā)最大連接數(shù)-服務(wù)器響應(yīng)最大連接數(shù):

  mysql> show global status like 'max_used_connections';

11、并發(fā)最大連接數(shù)-當(dāng)前連接數(shù):

  mysql> show global status like 'connections';

12、并發(fā)最大連接數(shù)-線程隊(duì)列(值越小越好):

  mysql> show variables like 'back_log';

13、臨時(shí)表:

  mysql> show global status like 'created_tmp%';

臨時(shí)表比較大無法在內(nèi)存完成時(shí)就不得使用磁盤文件,如果'created_tmp_tables非常大,則可能是系統(tǒng)中的排序操作過多,或者是表連接方式優(yōu)化不夠。

14、mysql服務(wù)器對(duì)臨時(shí)表的配置:

  mysql> show variables where variable_name  in ('temp_able_siae','max_heap_table_size');

當(dāng)臨時(shí)表空間小于max_heap_table_size時(shí),才能全部放入內(nèi)存。

15、表掃描情況:

  mysql> show global status like 'handler_read%';

  mysql> show global status like 'com_select';

  如果表掃描率超過4000,說明進(jìn)行太多表掃描,可能索引沒有建好,增加read_buffer_size值會(huì)有好處,但不要查8M。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容