InnoDB change buffer 一種重要的數(shù)據(jù)變更日志
創(chuàng)新互聯(lián)是專業(yè)的二連浩特網(wǎng)站建設(shè)公司,二連浩特接單;提供網(wǎng)站建設(shè)、成都做網(wǎng)站,網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行二連浩特網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!
Change buffer的主要目的是將對二級索引的數(shù)據(jù)操作緩存下來,以此減少二級索引的隨機(jī)IO,并達(dá)到操作合并的效果。
在MySQL5.5之前的版本中,由于只支持緩存insert操作,所以最初叫做insert buffer,只是后來的版本中支持了更多的操作類型緩存,才改叫change buffer。
當(dāng)更新/插入的非聚集索引的數(shù)據(jù)所對應(yīng)的頁不在內(nèi)存中時(shí)(對非聚集索引的更新操作通常會帶來隨機(jī)IO),會將其放到一個insert buffer中,當(dāng)隨后頁面被讀到內(nèi)存中時(shí),會將這些變化的記錄merge到頁中。當(dāng)服務(wù)器比較空閑時(shí),后臺線程也會做merge操作
但change buffer會占用buffer pool,并且在非聚集索引很少時(shí),并不總是必要的,反而會降低buffer pool做data cache的能力。
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.
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.
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 |
+---------------------+-------------+-------------------------------+
沒有對比,不知道這個結(jié)果的性能好壞。