MySQL & InnoDB (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
How does the Buffer Pool LRU (Least Recently Used) eviction algorithm prevent buffer pollution?
senior LevelCode ExampleSystem DesignMySQL
In Simple Words:
A standard LRU cache would be ruined by a single large full table scan (e.g. mysqldump) that flushes out all active hot pages.
- InnoDB Solution: The LRU list is split into two sub-lists: New (Young) Sublist (top 63%) and Old Sublist (bottom 37%).
- New pages enter at the midpoint (head of the Old sublist).
- A page only moves to the Young sublist if it is accessed again after a delay threshold (
innodb_old_blocks_time, default 1,000ms). - One-off table scans read pages into the Old sublist, where they expire rapidly without displacing hot production cache!
text
InnoDB LRU List Structure:
[Head: Most Recently Used]
│
[Young Sublist (63%)] ◄── Hot cached pages
│
[Midpoint Insertion Point] ◄── Newly read pages land here!
│
[Old Sublist (37%)] ◄── Candidate pages for eviction
│
[Tail: Evicted First]