A B-tree index turns a slow table scan into a fast lookup, at the cost of writes.
A sorted lookup table at the back of the book. Without it the database reads every page; with it, it jumps straight to the row.
It's usually the difference between a 4-second query and a 4-millisecond one, and knowing when an index WON'T be used is the real skill.
An index is a sorted side structure — typically a B-tree — that maps a column's values to their rows, so the database can seek directly instead of scanning every row. Indexes make reads on WHERE, JOIN, and ORDER BY columns dramatically faster, but each one adds storage and slows writes, since every INSERT, UPDATE, and DELETE must maintain it.
A B-tree index keeps indexed values sorted with pointers to rows, turning an O(N) scan into an O(log N) seek. Index the columns you filter, join, and sort on. Composite indexes help left-to-right only. The tradeoff: faster reads, slower writes, more storage — so index deliberately and verify with EXPLAIN.
what is a database index? — Hussein Nasser, 5:12