Pages, storage and the buffer pool
Trace records through pages and buffer-pool residency, then separate hit, miss and dirty-page reasoning from recovery protocol. Storage foundations · Databases.
A query asks for one row, but the storage layer moves a page. Follow the page before you blame the query.
The page behind the row
SQL speaks about rows. In this paged-storage model, physical storage groups records into pages so the engine can move and manage a bounded chunk of data. A page may contain several records, or entries from an index. The logical request can identify one row, but the physical read brings the page that contains the row into the working memory used by the storage engine.
That distinction matters when a request touches nearby rows. The query still asks for rows and applies predicates to rows. The storage layer reasons about which pages are available and which pages must be fetched. Page capacity, file format and page size depend on the engine and configuration. The lesson uses page labels to expose the movement boundary without promising a universal size or latency.
The first scene starts with durable pages P1, P2 and P3. The buffer has P1 resident, and the incoming request is shown before its result is revealed. The learner must connect the logical row location to the page request, then compare the resident-page hit with the absent-page miss before the terminal step.
A logical request and a residency answer live at different layers. “Find the row with this key” identifies a record through the table or index model; it does not say whether the containing page is already in the database buffer. The buffer pool tracks the engine-owned page copy. An operating-system or device cache below that layer may affect the cost of a read, but it does not by itself turn the page into a database-buffer hit. Keep the request, page location and residency evidence separate.
Pages, residency and dirty state
Read the steps as text
- Durable pages P1, P2 and P3 exist. P1 is resident, and the incoming request names row R-17 on P1; its result is withheld.
- The request names a row on resident P1. No write or replacement is part of this read.
- The next request names R-42 on absent P2. A free slot is available in this frame, so the immediate load decision is separated from victim selection.
- P2 is resident and the next event updates R-42 in memory. No commit, flush ordering or recovery log is shown.
- A resident page gives a hit, an absent page needs a load, and an in-memory change makes the page dirty; recovery and commit remain separate owners.
When the requested row is in resident P1, the request is a buffer-pool hit in this model. The storage layer can use the in-memory page copy without loading P1 again. When the request names a row in absent P2, it is a miss. P2 must become resident before the request can inspect that row. If the buffer has a free slot, the load fills it. If it does not, a replacement decision becomes necessary, but the request’s miss alone does not identify the victim.
Residency is a state, not a policy
Suppose an update changes a record in resident P2. The immediate physical fact is that the in-memory page now differs from its stored version: P2 is dirty. This lesson names the state so later scenes can distinguish a read hit from a modified copy. It does not decide when a commit is durable, which log records must precede a flush, or how recovery reconstructs pages. Those belong to the transaction and recovery owner.
The faded scene uses a fresh table. Two buffer slots hold Q1 and Q3; Q1 is clean and explicitly eligible for replacement, while Q3 is pinned and cannot be selected. There is no free slot, no other memory constraint, and the request for a row in absent Q2 must proceed. Those givens make the local conclusion precise: Q2 is a miss, and Q1 is the eligible victim in this fixed teaching model. The scene is not an LRU or allocator simulation. If the scene instead showed no eligible victim, the honest conclusion would be that the request waits or needs another resource decision; “evict some page” would not follow.
Residency is therefore not the same as eviction eligibility. A page can be present because a current operation needs it, yet be unavailable as a victim while it is pinned or otherwise protected. A clean page is a useful fact about whether this in-memory copy differs from its stored version, but cleanliness alone does not select it for replacement. The victim conclusion needs the complete local premises: no free slot, a request that must proceed, and one explicitly eligible page.
A bounded victim case
Read the steps as text
- A different table has Q1, Q2 and Q3. Two buffer slots hold Q1 and Q3, and the incoming request names row R-9 on resident Q3.
- Q3 is resident and clean, so the first request does not need replacement. The next request names absent Q2; both slots are occupied, Q1 is clean and eligible, Q3 is pinned, and the request must proceed.
- The second request names absent Q2. Both slots are occupied; Q1 is the only stated eligible clean victim, Q3 is pinned, and the request must proceed.
- The bounded replacement case is now complete.
The point is to separate evidence from policy. Seeing Q3 in the buffer proves a request for a row in Q3 can use that resident page. Seeing Q2 absent proves a request for Q2 is a miss. Only the added assumptions about free capacity, pinning, cleanliness and the required operation justify the stated replacement. An actual engine may also account for concurrent users, durability rules and other constraints; none are silently invented in this qualitative scene.
Recap
- Pages group records or index entries for physical movement; rows remain the logical query unit.
- A resident page gives a hit, while an absent page gives a miss that needs a load.
- Dirty and replacement conclusions require their visible premises; recovery, concurrency and allocator policy remain separate owners.
Why the index lesson comes first
A B+ tree narrows a search to a small set of index pages and then may lead to a data page. This lesson explains what happens after an access path names pages: residency and movement are still physical concerns. It does not repeat separator routing, leaf links or index maintenance, and it does not turn one observed page trace into a universal optimizer rule.
Next Row and column layouts: compare how the same logical relation groups values for different request shapes, then weigh compression trade-offs.
For a concrete access-pattern connection, practise hash maps in Fundamentals: a key lookup names an entry, while a database also has to account for the page that carries it.