Try
↑ ↓ move↵ openesc close

Curriculum · Module 07, Storage Engines

Lesson 1 · 7 topics · 29 min · Beginner · 0/7 done

B-trees and page writes

Why a tree of pages keeps lookups short, what an insert costs when a page splits, and how a write-ahead log lets the engine put off writing pages.

What each topic covers

  • Why a database stores sorted keys in wide pages, and why a tall, thin tree would make every lookup slow.
  • How a lookup picks one child per level, and how an insert into a full page splits it and may grow the tree.
  • Watch pages split, then compare random keys, ascending keys and a tree with no log.
  • Write amplification in a B-tree comes from writing a page for a record, and random keys make it worse.
  • A write-ahead log turns a random page write into an append, so the engine can write dirty pages later and in batches.
  • A checkpoint writes the dirty pages. Rare checkpoints write fewer pages and make recovery longer.
  • Three quick checks on tree height, page splits and the log, with the sources behind the lesson.

Topics

  1. 1A disk reads pages, not keys3 min
  2. 2Walking down, splitting up4 min
  3. 3Insert thousands of keys and count the pages7 min
  4. 4One small record, one whole page4 min
  5. 5The log lets the pages wait4 min
  6. 6How often to write the pages out4 min
  7. 7Pages, splits and the log3 min

Practise this lesson

8 interview questions on b-trees, with worked answers and sources.

Practise these

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms