mysql中的handler_read_%

來源:互聯網
上載者:User

標籤:text   pop   一點   ext   mod   tracking   sha   ges   gen   

  1. mysql> show status like ‘handler_read_%‘;
  2. +-----------------------+-------+
  3. | Variable_name | Value |
  4. +-----------------------+-------+
  5. | Handler_read_first | 1 |
  6. | Handler_read_key | 1 |
  7. | Handler_read_last | 0 |
  8. | Handler_read_next | 0 |
  9. | Handler_read_prev | 0 |
  10. | Handler_read_rnd | 0 |
  11. | Handler_read_rnd_next | 21 |
  12. +-----------------------+-------+
  13. 7 rows in set (0.01 sec)
如上所示,mysql中關於read的計數器,有7個。他們的數值對於系統的狀況的瞭解,對於系統的調優都十分重要。我們應該理解他們的含義。本文是自己的一些理解。
首先7個計數器,我們應該分為兩部分:
1)對索引讀的計數器:前面的5個都是對索引讀情況的計數器,
     Handler_read_first:是指讀索引的第一項(的次數);
     Handler_read_key:是指讀索引的某一項(的次數);
     Handler_read_next:是指讀索引的下一項(的次數);
     Handler_read_last:是指讀索引的最後第一項(的次數);
     Handler_read_prev:是指讀索引的前一項(的次數);
5者應該有四種組合:
1. Handler_read_first 和 Handler_read_next 組合應該是索引覆蓋掃描
2. Handler_read_key 基於索引取值
3. Handler_read_key 和 Handler_read_next 組合應該是索引範圍掃描
4. Handler_read_last 和 Handler_read_prev 組合應該是索引範圍掃描(orde by desc)

2)對資料檔案的計數器:後面的2個都是對資料檔案讀情況的計數器,
Handler_read_rnd:
The number of requests to read a row based on a fixed position. This value is high if you are doing alot of queries that require sorting of the result. You probably have a lot of queries that require MySQL toscan entire tables or you have joins that do not use keys properly.

Handler_read_rnd_next
The number of requests to read the next row in the data file. This value is high if you are doing a lot oftable scans. Generally this suggests that your tables are not properly indexed or that your queries arenot written to take advantage of the indexes you have.這裡很重要的一點要理解:索引項目之間都是有順序的,所以才有first, last, next, prev等等,所以前面的5個都是對索引讀情況的計數器,而後面的2個是對資料檔案的讀情況的計數器。很顯然的一點:後面的2個 Handler_read_rnd 和 Handler_read_rnd_next 是越低越好,如果很高,應該進行索引相關的調優。而Handler_read_key的數值肯定是越高越好,越高代表使用索引讀很高。其他的計數器,要具體情況具體分析 
 
頂

mysql中的handler_read_%

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.