A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Buffer Pool Management and Cache Replacement Policies

College Depth 95 in the knowledge graph ☐ I know this ☆ Set as goal
2topics build on this
357prerequisites beneath it
See this on the map →
Physical Storage: Pages, Records, and Heap FilesMemory Management Fundamentals→→Crash Recovery: Undo and Redo Logging
buffer-pool cache replacement-policy LRU FIFO

Core Idea

Buffer pools cache frequently accessed pages in memory to minimize disk I/O. Pages are identified by frame numbers and tracked with metadata (dirty bit, pin count, reference time). Replacement policies decide which page to evict when full: LRU (least-recently-used) works well for many workloads, FIFO is simpler, clock algorithms approximate LRU with less overhead. Pinning prevents eviction of critical pages.

Explainer

From your study of physical storage, you know that database data lives on disk in fixed-size units called pages (typically 4KB or 8KB). Disk access is orders of magnitude slower than memory access — roughly 10 milliseconds for a random disk read versus 100 nanoseconds for a memory access, a factor of 100,000. The buffer pool exists to bridge this gap. It is a region of main memory divided into frames, each sized to hold exactly one page. When the database engine needs a page, it first checks the buffer pool; if the page is already there (a hit), it avoids the disk entirely. If not (a miss), it reads the page from disk into a free frame.

The interesting problem arises when the buffer pool is full and a new page must be brought in. Some existing page must be evicted to make room, and the choice of which page to evict has enormous performance implications. The LRU (least-recently-used) policy evicts the page that has gone the longest without being accessed, based on the intuition that recently used pages are likely to be used again soon. LRU works well for many database workloads but requires maintaining a precise access ordering — typically a doubly-linked list that gets updated on every page access, which adds overhead.

FIFO (first-in, first-out) is the simplest alternative: evict whichever page has been in the buffer pool the longest, regardless of how recently it was accessed. It is cheap to implement but performs poorly when old pages are frequently re-accessed. The clock algorithm offers a practical middle ground. It arranges frames in a circular buffer with a "clock hand" pointer. Each frame has a reference bit set to 1 whenever the page is accessed. When eviction is needed, the clock hand sweeps around: if a frame's reference bit is 1, it gets reset to 0 and the hand moves on; if it is 0, that frame is evicted. This approximates LRU — recently accessed pages get a second chance — with far less bookkeeping overhead, making it the policy most real database systems actually use.

Two additional pieces of metadata are critical. The dirty bit tracks whether a page has been modified since it was read from disk. A clean page can be evicted instantly (the disk copy is still valid), but a dirty page must be written back to disk before eviction, doubling the I/O cost. The pin count tracks how many operations are currently using a page — a pinned page cannot be evicted under any policy, because an active transaction or operation depends on it being in memory. Understanding these mechanics explains why database tuning often focuses on buffer pool sizing: a larger buffer pool means more pages fit in memory, more accesses are hits, and fewer expensive disk I/Os occur.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Fixed-Point Number Representation → Two's Complement Representation → Overflow and Underflow Detection → Binary Adders: Half-Adders and Full-Adders → Full Adder and Carry Propagation → Carry Lookahead Adder Design → Half Adder Circuit Design → Multiplication Circuit Design → Sequential Circuit Design → Registers and Register Files → Instruction Set Architecture (ISA) → Assembly Language Basics → Memory Organization and Addressing → Memory Hierarchy → Memory Management Fundamentals → Buffer Pool Management and Cache Replacement Policies

Longest path: 96 steps · 357 total prerequisite topics

Prerequisites (2)

Leads To (1)