当前位置:网站首页>mysql性能監控和sql語句

mysql性能監控和sql語句

2022-06-26 10:48:00 波哥

1、查詢緩存:

mysql> show variables like '%query_cache%';

2、緩存在Cache中線程數量thread_cache_size:

 mysql> show variables like 'thread%';

3、DB已連接的線程數:

mysql> show status like 'connections';

4、當前連接線程狀態:

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、索引讀取統計:

mysql> show global status like 'key_blocks_u';

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

9、並發最大連接數-允許最大連接數(一般500到800比較合適):

mysql> show variables like 'max_connections';

10、並發最大連接數-服務器響應最大連接數:

mysql> show global status like 'max_used_connections';

11、並發最大連接數-當前連接數:

mysql> show global status like 'connections';

12、並發最大連接數-線程隊列(值越小越好):

mysql> show variables like 'back_log';

13、臨時錶:

mysql> show global status like 'created_tmp%';

臨時錶比較大無法在內存完成時就不得使用磁盤文件,如果'created_tmp_tables非常大,則可能是系統中的排序操作過多,或者是錶連接方式優化不够。

14、mysql服務器對臨時錶的配置:

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

當臨時錶空間小於max_heap_table_size時,才能全部放入內存。

15、錶掃描情况:

mysql> show global status like 'handler_read%';
mysql> show global status like 'com_select';

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

原网站

版权声明
本文为[波哥]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260950314636.html