Continue where you left off ×
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.
The idea in 30 seconds
A database finds one row by following a short chain of signposts, called an index, instead of checking every row in turn.
Fetching anything at all, one page at a time, is a disk read, the same idea as an arm swinging on a 1956 machine, only faster now.
A page is not one row and not one signpost. It is a few hundred of either, fetched together in a single trip.
Ten million rows only need three pages of signposts, because each page holds hundreds, not one.
The fourth trip in “four reads” is not a signpost. It is the shelf holding the actual row.
Checking every row in order, a scan, is one steady walk rather than ten million separate trips, which is why it takes seconds, not days.
Read the story
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 plans Already 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
Connects to
Storage Engines Data Systems Partitioning Data Systems Storage Extras: richer indexes, warehouse schemas, column tricks Data Systems Transactions Data Systems The Memory Hierarchy (cache, locality, the memory wall) How Computers Work Complexity & Big-O DSA Arrays & Strings DSA Hashing DSA Trees (BST, balancing, heaps, tries) DSA Sorting & Searching DSA The Right Book for the Job (databases, deeply) System Design The Slate, Properly (caching to real depth) System Design Database Internals, the deep-dive set Database Internals Foundations #04: Hashing (O(1) "yaad") DSA The Birthday Paradox Mind Blown The 99 Percent Test That Is Usually Wrong Mind Blown Fold a Paper to the Moon Mind Blown Mark as read Saved in this browser, and to your account when you sign in.