Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 01 · Mind Blown · Numbers that run away · about 28 min to read

Watch: The B-tree: one row in ten million, in four reads
▶ VideoPlay it as a journeyTutor comes with a plan

One Row in Ten Million

One Row in Ten Million
One Row in Ten Million · Open board

The library picture in the Mind Blown track: ten million books, three signposts, one book found. The drawing says you can find one book in ten million in four stops. That is right, and this lesson shows why.

Before you start. You need to be comfortable counting, and with the idea that multiplying a number by itself a few times gets big fast, the same idea behind Fold a Paper to the Moon. Nothing else: no code, no maths past that.

Lesson 4 of 73 in Mind Blown

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1956: a warehouse of spinning disks, built to end the wait
  • The trip that costs the same every time: the disk read
  • Ten million entries, and what one of them is called: the row
  • Checking every row without the wait: why order beats hopping around
  • The card that skips almost all of them: the index
  • A card never comes alone: the page
  • Four stops, and the one that is not a signpost
  • One name for the whole arrangement: the database
  • Where 407 signposts on one page comes from
  • The real tree for ten million rows
  • Scan versus the four trips, in units that survive a hardware generation
  • More comparisons, and it still wins
  • What the index costs on every write
  • When the library is right to ignore its own index
  • Where the ten-million intuition breaks, at a billion rows

Terms it explains: Mind Blown, B-tree, heap, 40 ms, 263×, 0.4 ms, 4,775×, 0.32 ms, 937×, 4 µs, 1 bit, log₂(407) = 8.67 bits, 1.05 GB, not monotonic, 32,000× less, 27 comparisons, page read, Page splits, 54,645, Updates, rightmost, 19,500 inserts/s on NVMe, s = 0.86%, bitmap heap scan, 54.7%, 4 levels, 77 s, 400, 160,000, 64,000,000, 7 levels, about 24 guesses, With PostgreSQL,.

Review Mind Blown