標籤:text pop 一點 ext mod tracking sha ges gen
- mysql> show status like ‘handler_read_%‘;
- +-----------------------+-------+
- | Variable_name | Value |
- +-----------------------+-------+
- | Handler_read_first | 1 |
- | Handler_read_key | 1 |
- | Handler_read_last | 0 |
- | Handler_read_next | 0 |
- | Handler_read_prev | 0 |
- | Handler_read_rnd | 0 |
- | Handler_read_rnd_next | 21 |
- +-----------------------+-------+
- 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_%