tezvyn:

What is a database page?

AI-drafted, machine-checkedSource: interviewbeginner
WHAT IT TESTS

storage fundamentals.

OUTLINE

a page is a fixed-size block, often 8KB, holding multiple rows; databases read and write whole pages because disk and OS I/O are block-oriented, amortizing seek cost and matching the buffer pool unit.

WHAT THIS TESTS The interviewer checks foundational knowledge of how databases sit on top of block storage and why they batch I/O into pages.

A GOOD ANSWER COVERS A page, sometimes called a block, is a fixed-size chunk of storage, commonly 8KB in PostgreSQL or 16KB in InnoDB, that holds many rows along with a page header and a slot directory mapping row identifiers to offsets. It is the smallest unit the database reads from or writes to disk and the unit it caches in the buffer pool. Databases use pages because the underlying media and operating system are block-oriented: a disk seek and rotation, or an SSD program operation, carries a large fixed cost regardless of how few bytes you want, so reading a single 200-byte row would waste almost all of that I/O. By transferring a whole page, the database amortizes that cost across many rows and benefits from spatial locality, since related rows often sit together. Pages also give a clean unit for the buffer manager, locking, checksums, and write-ahead logging. Fixed size keeps free-space management and addressing simple.

COMMON WRONG ANSWERS Believing each row is read or written individually. Confusing a page with a row or a table. Thinking page size is arbitrary rather than tuned to media and memory. Ignoring that pages are also the caching and recovery unit.

LIKELY FOLLOW-UPS What is inside a page header; how does the buffer pool cache pages; what happens when a row exceeds a page; why is page size a tuning knob.

ONE CONCRETE EXAMPLE To read one customer row, the engine asks the buffer pool for the 8KB page containing it. If absent, it issues a single page-sized read from disk, then serves that and neighboring rows on the same page from memory. A later query for an adjacent customer needs no I/O at all because the page is already cached.

Read the original → postgresql.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.