Module 2 · Indexes
Episode 10 B+ Trees: Search and Insert
▶ This video is coming to YouTube soon.
How does Postgres find one row out of 10,000 by reading just 3 pages? This episode builds a B+ tree from nothing, splits its leaves, grows a new root, and then checks every claim against a real Postgres index with pageinspect.
Chapters
- 0:00Intro
- 0:14Three pages out of 84
- 0:35Why not just keep the file sorted?
- 1:35The B+ tree in five rules
- 2:16Search: one page per level
- 3:14Insert: fill, overflow, split
- 4:18When the split reaches the root
- 5:08Why the tree stays short
- 5:35The code: insert
- 6:05The code: the split climbs
- 6:39Proof: a real B+ tree in Postgres
- 7:39Trade-offs
- 8:09Recap
- 8:39Next: B+ Tree: Delete