B-Tree Visualizer
Run a query and watch a B-tree find it, one node — one page read — at a time. A B-tree keeps keys and row data in every node, so a point lookup can even finish at the root.
How a B-tree works
A B-tree is a balanced, disk-friendly search tree. Each node is one page and holds many sorted keys with pointers between them — and, crucially, the row data is stored in every node, internal ones included. Because the tree is kept balanced (all leaves at the same depth), any key is found in at most the tree's height in page reads, and that height is the same worst case for every key.
Try this
- id = 30 finishes at the root in a single read — the data is right there.
- The range scan has to bounce up and down: with no links between leaves, reading the next range of values means climbing back to the parent between children.
That bouncing is exactly the problem the B+tree fixes. For the full write-up, see MySQL Internals.