What is a Page

A page is the smallest unit of data that a database reads from or writes to disk. When you query a single row, the database does not read just that row — it reads the entire page containing that row. Page sizes are typically 4 KB (SQLite), 8 KB (PostgreSQL), or 16 KB (InnoDB).

How it works

A database organizes its data files as a sequence of fixed-size pages. Each page contains multiple rows (or index entries) plus a small header with metadata like the page number, free space offset, and a checksum for corruption detection.

When you read a row, the database checks the buffer pool — an in-memory cache of pages. If the page is there (a cache hit), the read is fast. If not (a cache miss), the database reads the page from disk into the buffer pool. This is why database performance often depends on how much of the working set fits in the buffer pool.

When you write a row, the database modifies the page in the buffer pool and marks it as dirty. Dirty pages are not written to disk immediately — they are flushed in the background. The write-ahead log ensures durability: if the database crashes before a dirty page is flushed, the WAL replays the change on recovery.

Page size affects performance. Larger pages reduce the number of I/O operations for sequential scans but waste space when rows are small. Smaller pages are more efficient for random lookups but increase overhead for scans. Most databases choose a default page size that balances these trade-offs.

Why it matters

Understanding pages explains why "read one row" can be slow: if the page is not in the buffer pool, you pay the cost of a full disk read. It also explains why indexes matter — they tell the database which page to read instead of scanning every page in the table.

See How Storage Engines Work for the full picture of how pages are organized on disk.