DBW.

Intermediate

Buffer Pool Architecture and Page Table Design

Article diagram
November 11, 2026·10 min read

Buffer pool performance hinges on the page table's concurrency design and replacement policy's resistance to access pattern pathologies like sequential flooding.

The buffer pool is the central memory management component of a disk-oriented database system.
Its design determines how effectively a DBMS bridges the performance gap between volatile memory and persistent storage.
Because nearly every query touches the buffer pool, its architecture has an outsized impact on throughput, latency, and concurrency.
This article covers the core data structures, replacement policies, and concurrency considerations that define modern buffer pool implementations.

The Role of the Buffer Pool

A disk-oriented database stores its primary copy of data on non-volatile storage (SSD or HDD) in fixed-size units called pages, typically 4 KB, 8 KB, or 16 KB.
The buffer pool is a region of main memory organized as an array of frames, each capable of holding one page.
When the execution engine needs to read or modify a page, it requests that page from the buffer pool manager rather than issuing I/O directly.
If the page is already resident in a frame, the manager returns a pointer to it.
If not, the manager must evict a page from some frame (if the pool is full), read the requested page from disk into that frame, and then return the pointer.

This indirection gives the DBMS explicit control over memory management, as opposed to relying on the operating system's virtual memory subsystem.
Operating system page caches use generic replacement policies and lack knowledge of query semantics.
The DBMS, by contrast, can exploit access pattern information (sequential scans, index lookups, join traversals) to make better eviction decisions.

Page Table Design

The term "page table" in database internals refers to a hash table that maps page identifiers to frame locations in the buffer pool.
This is distinct from the OS-level page table used for virtual memory translation.

Page Identifier

A page is typically identified by a combination of a tablespace or file ID and a page number within that file.
Some systems pack this into a single 64-bit integer.
For example, InnoDB uses a (space_id, page_no) pair, while PostgreSQL uses a (RelFileNode, ForkNumber, BlockNumber) triple that gets hashed into the buffer table.

Hash Table Structure

diagram-2
Concurrent hash-table layouts: chained, linear probing (partitioned), and lock-free

The page table must support high-concurrency lookups with minimal contention.
Common implementations include:

  • Chained hashing with bucket-level latches. The hash table is divided into buckets, each protected by its own latch (lightweight lock). A lookup hashes the page ID to a bucket, acquires the bucket latch, and traverses the chain. This is the approach used in PostgreSQL's buffer mapping table.
  • Linear probing with partitioned latches. The table is divided into partitions, each covering a range of slots. This reduces pointer chasing but complicates deletion.
  • Lock-free hash tables. Some research systems use compare-and-swap (CAS) operations to avoid latching entirely, though these designs are more complex to implement correctly.

Frame Metadata

Each frame in the buffer pool has associated metadata, often stored in a buffer descriptor or buffer control block.
This metadata includes:

  • Page ID of the currently loaded page.
  • Pin count (also called reference count): the number of active users of this frame. A page cannot be evicted while its pin count is greater than zero.
  • Dirty flag: indicates whether the in-memory page has been modified since it was read from disk.
  • Latch: a read/write latch protecting the page contents from concurrent modification.
  • Usage or recency information: data used by the replacement policy (e.g., a reference bit for CLOCK, or a frequency counter for LFU-based schemes).

Walkthrough

The following walkthrough describes how a page request is serviced, from initial lookup through potential eviction and disk I/O.

Page Request Walkthrough

diagram-1
Control flow of GetPage handling hits, misses, eviction, and race recheck
function GetPage(page_id):
    // Step 1: Look up the page in the page table.
    bucket = hash(page_id) mod num_buckets
    acquire_latch(bucket)
    entry = search_chain(bucket, page_id)

    if entry is not null:
        // Page is already in the buffer pool.
        frame = entry.frame_id
        pin(frame)                    // increment pin count
        release_latch(bucket)
        acquire_page_latch(frame, mode)  // shared or exclusive
        return buffer_pool[frame]

    // Step 2: Page is not resident. Find a victim frame.
    release_latch(bucket)
    victim_frame = select_victim()     // uses replacement policy; marks frame as "in use"
                                       // to prevent concurrent eviction of the same frame

    if victim_frame is null:
        raise BufferPoolFullError      // all frames are pinned

    // Step 3: If the victim page is dirty, flush it to disk.
    // The victim frame must be held exclusively (e.g., via its buffer descriptor latch
    // or by being removed from the free/replacement list) before flushing, so that
    // no concurrent thread can pin or modify it during eviction.
    if is_dirty(victim_frame):
        flush_to_disk(victim_frame)

    // Step 4: Remove the victim's entry from the page table.
    old_page_id = get_page_id(victim_frame)
    old_bucket = hash(old_page_id) mod num_buckets
    acquire_latch(old_bucket)
    remove_entry(old_bucket, old_page_id)
    release_latch(old_bucket)

    // Step 5: Read the new page from disk into the victim frame.
    read_from_disk(page_id, victim_frame)

    // Step 6: Insert new mapping into the page table.
    acquire_latch(bucket)
    insert_entry(bucket, page_id, victim_frame)
    pin(victim_frame)
    set_dirty(victim_frame, false)
    release_latch(bucket)

    acquire_page_latch(victim_frame, mode)
    return buffer_pool[victim_frame]

A subtlety in real implementations: between releasing the bucket latch in Step 1 (page miss) and re-acquiring it in Step 6, another thread may have loaded the same page.
Production systems must handle this race, typically by rechecking the page table after acquiring the latch in Step 6 and backing off if the page was loaded concurrently.

Replacement Policies

When the buffer pool is full, the manager must choose a victim frame for eviction.
The replacement policy governs this decision.

LRU and Its Problems

Least Recently Used (LRU) evicts the page whose last access is oldest.
While simple, LRU is vulnerable to sequential flooding: a single large sequential scan can evict every useful page in the pool, replacing them with pages that will never be accessed again.

CLOCK

diagram-3
CLOCK eviction sweep with reference bits, pin checks, and the moving hand

The CLOCK algorithm approximates LRU with lower overhead.
Each frame has a reference bit.
On access, the bit is set to 1.
The eviction process sweeps a "clock hand" around the frames: if the current frame's bit is 1, it resets it to 0 and advances.
If the bit is already 0 and the pin count is 0, that frame is selected as the victim.

PostgreSQL uses a variant of CLOCK.
InnoDB uses a modified LRU list split into "young" and "old" sublists to mitigate sequential flooding.

LRU-K and 2Q

LRU-K (proposed by O'Neil, O'Neil, and Weikum) tracks the K-th most recent access time for each page rather than just the most recent.
A page that has been accessed only once will have no K-th access time and will be evicted preferentially.
LRU-2 (K=2) is the most common variant.
The 2Q algorithm by Johnson and Shasha achieves a similar effect with lower bookkeeping cost by maintaining two queues: a FIFO queue for first-time accesses and an LRU queue for pages accessed more than once.

Concurrency Considerations

The buffer pool is one of the highest-contention components in a database system.
Several techniques reduce this contention:

Multiple Buffer Pool Instances

Instead of a single buffer pool with one page table, the system can partition pages across multiple independent buffer pool instances.
A page's instance is determined by hashing its page ID.
Each instance has its own page table, free list, and replacement data structures.
MySQL/InnoDB uses this approach (configurable via innodb_buffer_pool_instances).

Latch Granularity

Fine-grained latching (per-bucket or per-partition) on the page table is essential.
Coarse-grained latching on the entire page table creates a serialization bottleneck.
The buffer descriptor latches (protecting pin counts and dirty flags) should also be lightweight, often implemented as spinlocks or atomic operations.

Pre-fetching and Asynchronous I/O

When the buffer pool manager can predict future page accesses (e.g., during a sequential scan or B-tree traversal), it can issue asynchronous read requests for upcoming pages before they are explicitly requested.
This hides I/O latency and keeps the execution engine from stalling.

Scan-Resistant Policies

As noted above, naive LRU is not scan-resistant.
Production systems either use modified LRU (InnoDB's young/old partitioning), CLOCK with sweep optimizations (PostgreSQL), or more sophisticated policies like ARC (Adaptive Replacement Cache), which dynamically balances between recency and frequency.

Interaction with the WAL

The buffer pool's dirty page management is tightly coupled to the write-ahead log (WAL).
The WAL protocol governing eviction (sometimes called the steal rule's logging requirement) states: before a dirty page can be flushed to disk, all WAL records describing modifications to that page must first be written to stable storage.
The buffer pool manager checks the page's log sequence number (LSN) against the flushed LSN of the WAL before writing the page back.
Violating this invariant can lead to unrecoverable states after a crash.

Note that this is distinct from, though related to, the "force log at commit" rule, which requires WAL records for a committing transaction to be flushed at commit time regardless of whether the corresponding dirty pages are evicted.
Together these two rules — write WAL before evicting a dirty page, and flush WAL at commit — form the foundation of crash recovery correctness in WAL-based systems.

Key Points

  • The buffer pool provides explicit, application-aware memory management that outperforms OS-level page caching for database workloads.
  • The page table is a concurrent hash table mapping page identifiers to buffer pool frame locations, and its latch granularity directly affects system scalability.
  • Each frame carries metadata (pin count, dirty flag, latch, and usage data) that coordinates concurrent access and guides eviction decisions.
  • Naive LRU replacement suffers from sequential flooding; production systems use CLOCK, LRU-K, 2Q, or partitioned LRU variants to achieve scan resistance.
  • Partitioning the buffer pool into multiple independent instances reduces contention on both the page table and replacement policy data structures.
  • Dirty page eviction is constrained by the WAL protocol: a page's WAL records must reach stable storage before the page itself can be flushed.
  • Race conditions during page loading (two threads loading the same page concurrently) require careful re-validation after latch re-acquisition.
  • Victim frame selection must ensure the frame is held exclusively during eviction to prevent concurrent threads from pinning or modifying it before the new page is installed.

References

Ramakrishnan, R. and Gehrke, J. Database Management Systems, 3rd Edition. McGraw-Hill, 2003. Chapters 9 and 13.

O'Neil, E., O'Neil, P., and Weikum, G. "The LRU-K Page Replacement Algorithm for Database Disk Buffering." Proceedings of the ACM SIGMOD International Conference on Management of Data, 1993.

Johnson, T. and Shasha, D. "2Q: A Low Overhead High Performance Buffer Management Replacement Algorithm." Proceedings of the 20th International Conference on Very Large Data Bases (VLDB), 1994.

Graefe, G. "A Survey of B-Tree Locking Techniques." ACM Transactions on Database Systems, Vol. 35, No. 3, 2010. (Covers buffer pool latch interactions with B-tree concurrency protocols.)

Megiddo, N. and Modha, D. "ARC: A Self-Tuning, Low Overhead Replacement Cache." Proceedings of the 2nd USENIX Conference on File and Storage Technologies (FAST), 2003.

Newsletter

Signal
over noise.

Database deep-dives, delivered once a week. Storage engines, query optimization, and the data layer.

You will receive Databases Weekly.