Database indexes.
The index at the back of a book, instead of reading every page to find a word.
- It’s in here somewhere…1
You want every mention of one word in a 900-page book.
- page 1… page 2… page 3…2
Without an index, the only option is to read every page in order — a full table scan.
- 3
The back-of-the-book index is a sorted shortcut: the word, then the exact pages.
- Page 412. Done.4
Because it’s sorted, you find the word in a handful of steps and jump straight there.
- 5
A database index is the same trick: even a billion rows are only a few dozen steps apart.
- Worth it for the lookups.6
It isn’t free — every write also updates the index, and it takes disk space.
Semicolony semicolony.dev/eli5/database-index/comic