【MySQL 5.7 Reference Manual】15.4.2 Change Buffer(變更緩衝)
阿新 • • 發佈:2018-12-20
15.4.2 Change Buffer(變更緩衝)
The change buffer is a special data structure that caches changes to secondary index pages when affected pages are not in the buffer pool. The buffered changes, which may result from INSERT, UPDATE, or DELETE operations (DML), are merged later when the pages are loaded into the buffer pool by other read operations. 變更緩衝是一個特殊的資料結構,當目標頁不在緩衝池中時,變更緩衝負責快取對二級索引頁的變更。被緩衝的變更內容可能是INSERT,UPDATE,或DELETE操作(DML)的結果。在下一次讀操作時這些頁會被載入緩衝池,之後變更緩衝中的內容將被合併。- InnoDB Standard Monitor output includes status information for the change buffer. To view monitor data, issue the SHOW ENGINE INNODB STATUS command.
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 4425293, used cells 32, node heap has 1 buffer(s) 13577.57 hash searches/s, 202.47 non-hash searches/s For more information, see Section 15.17.3, “InnoDB Standard Monitor and Lock Monitor Output”. 更多資訊,請參考15.17.3,“InnoDB標準監視器與鎖定監視器輸出”。
- The INFORMATION_SCHEMA.INNODB_METRICS table provides most of the data points found in InnoDB Standard Monitor output, plus other data points. To view change buffer metrics and a description of each, issue the following query:
- The INFORMATION_SCHEMA.INNODB_BUFFER_PAGE table provides metadata about each page in the buffer pool, including change buffer index and change buffer bitmap pages. Change buffer pages are identified by PAGE_TYPE. IBUF_INDEX is the page type for change buffer index pages, and IBUF_BITMAP is the page type for change buffer bitmap pages.
INNODB_BUFFER_PAGE
table can introduce significant performance overhead. To avoid impacting performance, reproduce the issue you want to investigate on a test instance and run your queries on the test instance.
For example, you can query the INNODB_BUFFER_PAGE table to determine the approximate number of IBUF_INDEX and IBUF_BITMAP pages as a percentage of total buffer pool pages.
例如,你可以查詢INNODB_BUFFER_PAGE,通過計算佔總緩衝池頁的百分比來確認IBUF_INDEX頁和IBUF_BITMAP頁的大致數量。
SELECT
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE PAGE_TYPE LIKE 'IBUF%'
) AS change_buffer_pages,
(
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
) AS total_pages,
(
SELECT ((change_buffer_pages/total_pages)*100)
) AS change_buffer_page_percentage;
+---------------------+-------------+-------------------------------+
| change_buffer_pages | total_pages | change_buffer_page_percentage |
+---------------------+-------------+-------------------------------+
| 25 | 8192 | 0.3052 |
+---------------------+-------------+-------------------------------+ For information about other data provided by the INNODB_BUFFER_PAGE table, seeSection 23.31.1, “The INFORMATION_SCHEMA INNODB_BUFFER_PAGE Table”. For related usage information, see Section 15.15.5, “InnoDB INFORMATION_SCHEMA Buffer Pool Tables”. 更多關於INNODB_BUFFER_PAGE表所提供的其他資料的資訊,請參考23.31.1,“INFORMATION_SCHEMA INNODB_BUFFER_PAGE表”。相關用法,請參考 15.15.5,“InnoDB INFORMATION_SCHEMA緩衝池表”。
- Performance Schema provides change buffer mutex wait instrumentation for advanced performance monitoring. To view change buffer instrumentation, issue the following query:
WHERE NAME LIKE '%wait/synch/mutex/innodb/ibuf%';
+-------------------------------------------------------+---------+-------+
| NAME | ENABLED | TIMED |
+-------------------------------------------------------+---------+-------+
| wait/synch/mutex/innodb/ibuf_bitmap_mutex | YES | YES |
| wait/synch/mutex/innodb/ibuf_mutex | YES | YES |
| wait/synch/mutex/innodb/ibuf_pessimistic_insert_mutex | YES | YES | +-------------------------------------------------------+---------+-------+ For information about monitoring InnoDB mutex waits, see Section 15.16.2, “Monitoring InnoDB Mutex Waits Using Performance Schema”. 更多關於監控InnoDB互斥等待的資訊,請參考15.16.2,“使用Performance Schema監控InnoDB互斥等待”。