Scrivio Interview library
InternalsFoundations7 min read · updated 12 November 2026

Describe the main parts of InnoDB's memory and disk architecture: buffer pool, change buffer, adaptive hash index, log buffer, redo log, undo tablespaces and the doublewrite buffer. What does each do?

The buffer pool caches 16 KB data and index pages in memory, using an LRU list split into young and old parts so a big scan cannot push out hot pages. The change buffer delays changes to secondary index pages that are not in memory, the adaptive hash index adds an automatic in-memory hash over hot B-tree pages, and the log buffer and redo log record every change before data pages are written, which makes crash recovery possible. Undo logs keep old row versions for rollback and consistent reads, and the doublewrite buffer protects pages from being half-written during a crash.

Why this question is asked

InnoDB is the storage engine behind almost every MySQL table, and most tuning and troubleshooting questions come back to one of its parts: a cold buffer pool, a long-running transaction growing the undo logs, or a redo log that is too small for the write rate. Interviewers ask for the whole picture because knowing what each part does lets us reason about problems instead of memorising settings. In this answer, we will follow a write through InnoDB, and along the way explain the buffer pool and its LRU, the change buffer, the adaptive hash index, the log buffer and redo log, the undo tablespaces and the doublewrite buffer.

1A Quick Recap: Pages and the Write Path

InnoDB stores tables and indexes as B-trees made of pages, 16 KB each by default. Every read or write works on whole pages: to read one row, InnoDB brings the page that holds it into memory.

The basic trick of any database engine is to change pages in memory and write them to disk later, in the background, because random writes to data files are slow. That raises a safety question: what if the server crashes before the changed pages reach disk? Most of InnoDB's parts exist either to make memory access fast or to keep that delayed writing safe.

Step throughInnoDB memory and disk
  1. Buffer pool (memory)16 KB data and index pages, LRU with young and old sublists
  2. Change buffer and adaptive hash indexinside the buffer pool's memory
  3. Log buffer (memory)redo records waiting to be written
  4. Redo log (disk)write-ahead log for crash recovery
  5. Undo tablespaces (disk)old row versions for rollback and MVCC
  6. Doublewrite buffer, then data files (disk)pages written twice to survive torn writes

6 layers, from the top down. Step through them one at a time.

2The Buffer Pool and Its Midpoint LRU

The buffer pool is InnoDB's cache of pages, and usually the largest use of memory on a MySQL server. When a query needs a page, InnoDB looks in the buffer pool first; if the page is there, no disk read happens.

When the pool is full, InnoDB must evict a page, and it uses a least recently used list, an LRU. But a plain LRU has a weakness: a single full table scan, for a report or a backup, touches every page once and would push all the frequently used pages out. So InnoDB splits the list into a young sublist of hot pages and an old sublist, about 3/8 of the pool by default (innodb_old_blocks_pct = 37). A newly read page is inserted at the midpoint, at the head of the old sublist, not at the top. It moves into the young sublist only if it is accessed again after staying in the pool for at least innodb_old_blocks_time, 1000 ms by default. A scan reads each page several times within a few milliseconds and then never again, so its pages stay in the old part and age out, while the hot pages stay young.

Text
SHOW ENGINE INNODB STATUS\G
-- Buffer pool size 524288 (pages of 16 KB = 8 GB)
-- Old database pages 193520
-- Pages made young 1852201, not young 9812210

3The Change Buffer and the Adaptive Hash Index

Inserting a row changes the clustered index and every secondary index. The secondary index pages that need changing are often not in memory and lie in random places on disk. For non-unique secondary indexes, InnoDB can record the change in the change buffer instead of reading the page immediately, and merge it later when the page is read for another reason or in the background. That turns many random reads into fewer, batched ones. It cannot do this for unique indexes, because checking uniqueness requires reading the page anyway.

The adaptive hash index is an optimisation InnoDB builds by itself. When it sees the same index pages searched again and again with the same kind of key, it builds an in-memory hash table over them, so lookups can jump to the row without walking down the B-tree. It helps read-heavy point lookups, but it can become a point of contention under mixed workloads.

Both are switched off by default in MySQL 8.4, which sets innodb_change_buffering to none and innodb_adaptive_hash_index to OFF, because on fast SSDs their benefit is often smaller than their cost; check your version and test before turning them on.

4The Log Buffer and the Redo Log

When a transaction changes a page in the buffer pool, InnoDB also writes a small redo record describing the change, first into the log buffer in memory, then into the redo log on disk. This is write-ahead logging: the redo record reaches disk before the changed page does. With the default innodb_flush_log_at_trx_commit = 1, the redo log is flushed to disk at every commit, so a committed transaction is durable even though its data pages are still only in memory.

After a crash, InnoDB reads the redo log and reapplies every change that had not yet reached the data files. The size of the redo log, innodb_redo_log_capacity since MySQL 8.0.30, limits how far the data files can fall behind: when the redo log fills up, InnoDB must flush dirty pages quickly to free space, which shows up as sudden write stalls.

SQL
SET autocommit = 0;
UPDATE accounts SET balance = balance - 100 WHERE id = 7;
-- page changed in the buffer pool, redo record in the log buffer
COMMIT;
-- redo log flushed to disk: the change is durable
-- the data page itself is written later by background flushing
Step throughA committed update in InnoDB
TransactionBuffer poolUndo logRedo logData files
save the old row version
change the page in memory
write the redo record
COMMIT: flush redo to disk
durable
later: flush the dirty page via doublewrite

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

The data page reaches disk after the commit; the redo log covers the gap.

5Undo Tablespaces and the Doublewrite Buffer

Before changing a row, InnoDB copies the old version into an undo log, stored in undo tablespaces (two by default, undo_001 and undo_002). Undo serves two purposes. If the transaction rolls back, InnoDB uses it to restore the old values. And for MVCC, a consistent read in another transaction that started earlier follows the undo chain back to the version it is allowed to see. That is why a transaction left open for hours makes undo grow: the purge thread cannot remove old versions that someone might still need.

The doublewrite buffer solves a different problem, the torn page. A 16 KB page is written to disk in pieces, and a power failure in the middle can leave a page half old and half new. The redo log cannot repair such a page, because redo records assume a valid page to apply to. So InnoDB first writes each batch of dirty pages to the doublewrite area, separate files since MySQL 8.0.20, flushes it, and then writes the pages to their real places. After a crash, a torn page in the data files is replaced by its intact copy from the doublewrite area, and then redo is applied.

6Follow-up questions

Why does the LRU have a midpoint insertion strategy?

To stop one-time scans from evicting hot pages. A new page enters at the head of the old sublist, about 3/8 from the tail, and is promoted to the young sublist only if it is accessed again after innodb_old_blocks_time, 1000 ms by default. Pages read by a table scan or a backup are touched in quick succession and then never again, so they age out of the old sublist without disturbing the working set in the young sublist.

What is the difference between redo and undo?

Redo records how to repeat a change, and is used after a crash to bring data files forward to the last committed state. Undo records how to reverse a change, and is used for rollback and to build older row versions for consistent reads. Redo moves the database forward; undo lets it look or go back.

Can the doublewrite buffer be turned off?

It can, with innodb_doublewrite, and some file systems or storage that guarantee atomic 16 KB writes make it unnecessary. On ordinary storage, turning it off risks unrecoverable torn pages, so the small write cost is usually worth keeping.

7Conclusion

In this answer, we followed InnoDB's main parts: the buffer pool caches 16 KB pages with a midpoint LRU that protects hot pages from scans; the change buffer delays changes to non-unique secondary index pages that are not in memory; the adaptive hash index adds an automatic hash over hot B-tree pages, and both are off by default in MySQL 8.4. The log buffer and redo log make commits durable through write-ahead logging and enable crash recovery, undo tablespaces hold old row versions for rollback and MVCC, and the doublewrite buffer protects pages against torn writes during flushing.

What to say in the interviewAbout 90 seconds aloud

Open with

InnoDB stores everything in 16 KB pages, and the buffer pool is its in-memory cache of those pages. Its LRU is split into a young and an old sublist: new pages go in at the midpoint, the head of the old part, and only get promoted if they are read again after about a second, so a big scan or backup cannot flush out the hot pages.

Then, if they want more

The change buffer lets InnoDB record changes to non-unique secondary index pages that are not in memory and merge them later, saving random reads; it cannot work for unique indexes because uniqueness needs the page. The adaptive hash index is an automatic in-memory hash over frequently searched B-tree pages for faster point lookups.

In MySQL 8.4 both of those are off by default. For durability, every change produces a redo record in the log buffer, and at commit the redo log is flushed, so the commit is durable before the data page is written; after a crash InnoDB replays the redo.

The undo tablespaces hold old row versions, used for rollback and for MVCC reads, which is why long transactions make undo grow. Finally, the doublewrite buffer: dirty pages are written there first and then to their real place, so a page torn by a crash mid-write can be restored before redo is applied.

About this answer

Last updated
12 November 2026
Versions it names
MySQL 8.0, MySQL 8.4
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.
Official documentation
MySQL reference manual
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 "Describe the main parts of InnoDB's memory and disk architecture: buffer pool, change...": https://scrivio-interview-library.netlify.app/databases/mysql/72fb5687fd/