1. 基本結構:INNODB用least recently used (LRU) 算法來管理他的buffer_pool。 buffer_pool在内部被分隔為兩個list. a young list 和 a old list.
Young list 存儲那些高頻使用的緩存資料(預設占整個BUFFER的5/8)
Old list 存儲那些低頻使用的資料(預設占整個BUFFER的3/8)
2.使用機制:當一個新塊資料被從磁盤緩存到buffer當中,它預設被放在Old list的頭部,即midpoint。Old list内的任何一個塊資料被再次通路,innodb都會把它加入到Young list的頭部。但如果塊資料是被read-ahead機制通路,它不會馬上被加載到Young list。 當長期不使用的資料塊被擠到了Old list的尾巴,就會被系統回收。
3. 配置方式:
innodb_old_blocks_pct:設定 Young list 和 Old list 的比例。(default value is 37 (that is, 3/8 of the pool).
innodb_old_blocks_time:設定Old list内的資料塊被通路後到加入 Young list的延遲時間。預設是0,即馬上加入Young list。當臨時使用一些dump或全表掃描時,可是使用此參數避免大量的資料塊被回收。
4. 監控:show engine innodb status的BUFFER POOL AND MEMORY部分包含裡Old/Young list的使用情況
Old database pages:包含在Old list内的資料頁數
Pages made young:The number of old pages that were moved to the head of the buffer pool (the new sublist)
not young:he number of pages that have remained in the old sublist without being made new
youngs/s:導緻資料塊加入Young list的通路程序數(注:這裡是程序數,而不是資料塊數量)
non-youngs/s:沒有導緻……
young-making rate:Hits that cause blocks to move to the head of the buffer pool
not: Hits that do not cause blocks to move to the head of the buffer pool (due to the delay not being met)
(young-making rate and not rate will not normally add up to the overall buffer pool hit rate)
5. 新版的5.5的多pool 機制:設定innodb_buffer_pool_instances大于1,可使用多個pool, 使得通路競争被分散。每塊pool的大小等于innodb_buffer_pool_size/innodb_buffer_pool_instances,。(注意:每塊至少不能不要小于1G。)