InnoDB Buffer Pool

The InnoDB buffer pool is the memory area that holds data pages, index pages, undo pages, the change buffer, and the adaptive hash index. InnoDB normally reads data files without going through the operating system cache (O_DIRECT), so the buffer pool is effectively the only data cache. On a dedicated server, most of the memory goes to the buffer pool.

Key Specifications

ItemValue
Size settinginnodb_buffer_pool_size, default 128MB. Can be changed without a restart since 5.7
Common size50-80% of the memory of a dedicated server
Partitioninginnodb_buffer_pool_instances (splits lock contention), innodb_buffer_pool_chunk_size (resize unit, default 128MB)
Eviction ruleMidpoint-insertion LRU (new sublist and old sublist)
Old sublist ratioinnodb_old_blocks_pct, default 37 (about 3/8)
Promotion wait timeinnodb_old_blocks_time, default 1000ms
Dirty page writespage cleaner threads, adaptive flushing
Prewarming after restartDump the page list at shutdown, load it at startup (on by default, the most frequently used 25%)

How It Works

Figure. Midpoint-insertion LRU

block-beta
  columns 8
  h1["new sublist (about 5/8)"]:5 h2["old sublist (about 3/8)"]:3
  n1["Frequently used page"] n2["…"] n3["…"] n4["…"] n5["…"] o1["Newly read page"] o2["…"] o3["Page to evict"]
  class h1,h2 meta
  class n1,n2,n3,n4,n5 data
  class o1 hot
  class o2 muted
  class o3 warn

Diagram notes: the left side of the list is the most recently used end. A page newly read from disk is inserted not at the very front but at the head of the old sublist (Newly read page). The page moves up to the new sublist only if it is accessed again after innodb_old_blocks_time has passed. Pages read by a large scan are each used only once in a short time, so they circulate only inside the old sublist and drop off at the tail (Page to evict), and the Frequently used page entries in the new sublist are not pushed out.

Read-ahead. When many pages of one extent (64 pages) are read in order, linear read-ahead reads the next extent in advance (innodb_read_ahead_threshold, default 56).

Dirty pages. The page cleaner threads write the dirty pages at the LRU tail and the pages whose write would advance the checkpoint. Adaptive flushing increases the write volume to match the rate at which the redo log fills. innodb_max_dirty_pages_pct limits the dirty page ratio.

Operating system cache. On Linux, innodb_flush_method = O_DIRECT skips the operating system cache for data files and avoids double buffering. The default differs by version, so check it directly.

Configuration and Checks

SHOW VARIABLES LIKE 'innodb_buffer_pool%';
SET GLOBAL innodb_buffer_pool_size = 8 * 1024 * 1024 * 1024;   -- online resize (rounded to the chunk size)
SHOW STATUS LIKE 'Innodb_buffer_pool_resize_status';

-- Hit ratio: share of read requests that went to disk
SHOW GLOBAL STATUS WHERE Variable_name IN ('Innodb_buffer_pool_read_requests', 'Innodb_buffer_pool_reads');

SELECT POOL_ID, POOL_SIZE, FREE_BUFFERS, DATABASE_PAGES, MODIFIED_DATABASE_PAGES, HIT_RATE
FROM information_schema.INNODB_BUFFER_POOL_STATS;

-- Dump the current state before a restart
SET GLOBAL innodb_buffer_pool_dump_now = ON;

Comparison with Other DBMSs

InnoDBPostgreSQLOracleSQL Server
Large scan protectionold sublist and promotion wait timeRing bufferDirect path reads, RECYCLE poolLRU-2
Prewarming after restartDump and load (on by default)pg_prewarmNo built-in featureNo built-in feature

From the Articles

NOTE Default values can vary by version.

Related pages