An interactive explainer

An index turns 25,000 disk reads into 4. When it is allowed to.

Without an index the database reads every page of the table to find one row. With one it reads three nodes and a page. The part nobody tells you is how easily a query loses that — wrap the column in a function and the index cannot be walked at all, and ask for too many rows and the database goes back to the full scan on purpose.

Database indexes · B-trees · Query planning

Databases & Search · Intermediate · 11 min · How a database finds one row in a million — an interactive explainer on ViLearn, with a simulation and a knowledge check. All explainers.

Related: How Elasticsearch finds your needle in a billion documents · The list that only says no · Why two correct transfers can lose money