Scrivio Interview library
ConceptFoundations7 min read · updated 12 November 2026

What is a database page, and what is the buffer pool? Explain why reading one 100-byte row by primary key can read a whole page, and what the page sizes are in PostgreSQL and MySQL InnoDB by default.

A page is the fixed-size block in which a database stores table rows and index entries, and it is the unit the database reads, writes and caches: 8 KB in PostgreSQL and 16 KB in MySQL InnoDB by default. The buffer pool is the memory area that caches those pages, shared_buffers in PostgreSQL and innodb_buffer_pool_size in InnoDB. Reading one 100-byte row means reading the few index pages and the one data page that hold it, but if they are already in the buffer pool no disk I/O is needed at all.

Why this question is asked

Almost every database performance conversation eventually comes down to pages: why a query is fast the second time, why a server needs 64 GB of memory, why random keys make inserts slow. Interviewers ask this question to check that we picture the database as a page store with a cache in front of it, not as a list of rows. In this answer, we will see what a page holds, why the database never reads a single row from disk, how the buffer pool works and what happens to changed pages, and how hit ratio and working set tell us how much memory we need.

1A Quick Recap: What Is a Page?

A database file is not a stream of rows. It is divided into equal blocks called pages. PostgreSQL uses 8 KB pages (a compile-time setting, which almost nobody changes), and InnoDB uses 16 KB pages by default (set with innodb_page_size when the instance is created). Each page has a small header, an array of pointers to the rows it contains, the rows themselves and some free space. Index entries are stored in pages too.

The page is the unit of I/O. When the database needs anything from disk, it reads the whole page, and when it writes, it writes whole pages. That is simply how storage and operating systems work efficiently: reading 8 KB costs about the same as reading 100 bytes, while asking the disk for each row separately would be far slower.

SQL
-- PostgreSQL
SHOW block_size; -- 8192
-- MySQL
SELECT @@innodb_page_size; -- 16384
-- How many 100-byte rows fit? Roughly 8192 / (100 + per-row overhead of about 28) = about 60 in PostgreSQL

2Why One 100-Byte Row Reads Whole Pages

Suppose we run SELECT * FROM customer WHERE id = 42 and the table has 50 million rows. The database does not scan the table. It walks the primary key index, a B+ tree, from the root page down through one or two inner pages to a leaf page, which tells it where the row is. In PostgreSQL the leaf points to a page in the heap, the separate table file; in InnoDB the table itself is the primary key tree, so the leaf page holds the row.

So the lookup touches about three or four pages. Each page is 8 or 16 KB, so in the worst case we read 32 to 64 KB to return 100 bytes. That sounds wasteful, but notice two things. The upper pages of the index are used by every lookup, so they are almost always in memory. And the other rows on the data page come along for free, which is why reading neighbouring rows is cheap.

Step throughSELECT * FROM customer WHERE id = 42
  1. Read index root pagealmost always cached
  2. Read inner index pageusually cached
  3. Read index leaf pagefinds the row location
  4. Read data page8 KB in PostgreSQL, holds about 60 rows
  5. Page in buffer pool?
    YesReturn the row, no disk I/ONoRead the page from storage first

5 steps in order. Play them, or step through them one at a time.

A primary key lookup is a handful of page reads; the buffer pool decides whether any of them touch the disk.

3The Buffer Pool: A Cache of Pages

The buffer pool is a large area of memory divided into slots the size of a page. Every page the database reads goes through it: if the page is already there, that is a hit and costs only a memory access, measured in microseconds or less; if not, that is a miss, and the database reads the page from storage into a free slot, which costs from about a hundred microseconds on a fast SSD to milliseconds on network storage.

In PostgreSQL the buffer pool is shared_buffers, and PostgreSQL also benefits from the operating system's own file cache, so a page missing from shared_buffers may still come from memory. In InnoDB it is innodb_buffer_pool_size, often set to most of the server's memory on a dedicated database host, because InnoDB usually bypasses the OS cache for data files. A query never reads rows directly from disk; it always asks the buffer pool for pages.

4What Happens to Changed Pages

When we update a row, the database changes the page in the buffer pool, and the page becomes dirty, meaning it differs from the copy on disk. It does not write the page back at commit, because writing 8 KB randomly for every small change would be slow. Instead it writes a compact record of the change to the write-ahead log (WAL in PostgreSQL, the redo log in InnoDB) and flushes that log at commit. The log is written sequentially, which is fast, and it is enough to redo the change after a crash.

Dirty pages are written back later by background processes, the background writer and the checkpointer in PostgreSQL and the page cleaner threads in InnoDB. A checkpoint makes sure all pages changed before a certain point are on disk, so older log is no longer needed for recovery.

Step throughAn UPDATE and its pages over time
SessionBuffer poolWAL / redoData file
change row on page 7 (page now dirty)
append change record
COMMIT: flush log
durable, COMMIT returns
later: checkpoint or background writer writes page 7

5 messages in order. Play them, or step through them one at a time.

5Hit Ratio and Working Set

We cannot usually keep the whole database in memory, and we do not need to. What matters is the working set, the pages that queries touch regularly. A 2 TB database whose daily traffic touches only the last month's orders and their indexes may have a working set of 60 GB. If the buffer pool (plus, for PostgreSQL, the OS cache) holds that working set, most reads are hits.

The hit ratio is the share of page requests served from memory. In PostgreSQL we compute it from blks_hit and blks_read in pg_stat_database; in InnoDB from Innodb_buffer_pool_read_requests and Innodb_buffer_pool_reads. For an OLTP system we usually want well above 99 percent. A falling hit ratio and rising read I/O tell us the working set has outgrown memory, and that is when more memory, better indexes or archiving old data pays off.

SQL
SELECT datname, round(100.0 * blks_hit / nullif(blks_hit + blks_read, 0), 2) AS hit_pct
FROM pg_stat_database WHERE datname = 'shop'; -- 99.87
-- MySQL: 1 - Innodb_buffer_pool_reads / Innodb_buffer_pool_read_requests

6Follow-up questions

What happens when the buffer pool is full and a new page is needed?

The database evicts a page it thinks is least useful. PostgreSQL uses a clock sweep: each buffer has a usage count that is raised on access and lowered as the sweep passes, and a buffer with count zero is reused. InnoDB uses an LRU list with a midpoint insertion. If the chosen page is dirty, it must be written to disk first, which is why background writers try to keep enough clean pages available, so queries do not have to wait for a write before they can read.

Why not make pages much bigger to read more at once?

Bigger pages help scans but hurt random lookups and caching: each lookup reads more bytes it does not need, fewer distinct pages fit in memory, and writes of a full page cost more. 8 and 16 KB are a balance that works for mixed workloads; column stores, which mostly scan, use much larger blocks.

Does a hit in the buffer pool cost nothing?

It costs very little but not nothing: the database locates the buffer through a hash table, pins it and checks its visibility information. That is why a query that touches millions of cached pages can still take seconds; reducing pages touched is always the first optimisation.

7Conclusion

In this answer, we saw that databases store data in fixed pages, 8 KB in PostgreSQL and 16 KB in InnoDB, and always read and write whole pages. A primary key lookup touches a few index pages and one data page, and the buffer pool, shared_buffers or innodb_buffer_pool_size, decides whether those reads reach the disk. Changes are made in memory and made durable through the WAL or redo log, while dirty pages are written back later by background writers and checkpoints. Hit ratio and working set size tell us how much memory a database really needs.

What to say in the interviewAbout 90 seconds aloud

Open with

A page is the fixed-size block a database uses to store rows and index entries, and it is the unit of I/O and caching. PostgreSQL uses 8 KB pages and InnoDB 16 KB by default.

Then, if they want more

The database never reads a single row from disk; it reads the page that contains it. So a primary key lookup for a 100-byte row walks the B+ tree, the root, an inner page and a leaf, and then reads the data page, or in InnoDB the leaf already holds the row. That is three or four pages.

The buffer pool is the memory cache of pages, shared_buffers in PostgreSQL, which also leans on the OS page cache, and innodb_buffer_pool_size in MySQL. If the pages are in it, the lookup needs no disk I/O at all, and the top index levels nearly always are.

When we update, the page is changed in memory and becomes dirty; at commit only the WAL or redo record is flushed, which makes the change durable, and background writers and checkpoints write the dirty pages later.

To size memory I look at the working set, the pages queries touch regularly, rather than total data size, and at the hit ratio from pg_stat_database or the InnoDB buffer pool counters, aiming well above 99 percent for OLTP. When the pool is full, a page is evicted, and a dirty one must be written first.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is a database page, and what is the buffer pool? Explain why reading one 100-byte...": https://scrivio-interview-library.netlify.app/databases/storage-internals/d98199ae98/