Caching Pages in Memory
The buffer pool is a region of RAM that holds copies of disk pages. Almost every read and write goes through it, so a high hit rate is the single biggest factor in database performance.
Frames, Pins, and Dirty Bits
The pool is divided into fixed size frames, each holding one page.
- A pin count tracks how many operations currently use a frame so it cannot be evicted.
- A dirty bit marks a frame whose page was modified and must be written back before reuse.
- A page table maps page ids to frames for fast lookup.
Eviction
When the pool is full and a new page is needed, the manager picks a victim frame using a policy such as clock or LRU. If the victim is dirty, it is flushed to disk first. Pinned frames are never chosen.
Key idea
The buffer pool caches pages in pinned frames with dirty bits, and an eviction policy chooses unpinned victims, flushing them first if they were modified.