Part 4 of 5 · 1 min read
Eviction
Deciding which page to remove from a full buffer pool to make room for a new one.
Eviction
Think of a small kitchen counter that is already full. Making room for a new ingredient means first putting one of today's current items back in the pantry.
In plain words: eviction decides which page to remove from a full buffer pool, to make room for a newly requested page. A common strategy evicts the least recently used page, on the reasoning that a page used a while ago is less likely to be needed again soon than one used recently. A dirty page must be written back to disk before it can be evicted.
A worked example. When the buffer pool is full and a new page must be loaded, a page nobody has touched in a while is evicted first, and if that page happens to be dirty, it is written to disk before being removed from memory.
The key lines. No new code; eviction policy is an internal storage-engine algorithm, not SQL-level behavior.
Remember this
A buffer pool page can be clean (safe to discard immediately) or dirty (must be written to disk first). Eviction always respects this: a dirty page is written back before it is ever removed, never silently dropped.
Quick notes
- The buffer pool holds recently read disk pages in memory, serving repeated reads far faster than disk.
- A database manages this cache itself, since it understands its own access patterns.
- A dirty page has been modified in memory but not yet written back to disk.
- A dirty page must be written back before being evicted, never discarded directly.
- Eviction commonly removes the least recently used page to make room for a new one.