Skip to content
StackDecode
System Design
4. Database FundamentalsAnimated

B+ Tree Indexing

A B-tree variant where only leaves hold data, linked in order.

The idea

Leaves are linked, so range scans walk sideways without going back up the tree.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

App serversPrimary (writes)Replica 1 (read…Replica 2 (read…
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Step one: add indexes and cache.

step:
1/4
at:
App servers
1/7

The green dot is a request moving through the system.

Step by step

  1. 1Descend through internal nodes
  2. 2Reach the leaf holding the key
  3. 3Follow leaf links for ranges
  4. 4Insert causes splits that propagate up

Where it is used

Relational database indexes.

Watch out for

Wide keys reduce fan-out and slow the tree.

Related