System Design Visualized
Lesson C2.2

Indexes: why lookups are fast (and writes slower)

Play this lessonThis lesson comes with a live-code challenge and a chapter quiz.

Without an index, SELECT * FROM users WHERE email = ? scans every row: O(n). An index is a separate sorted structure (usually a B-tree) mapping the column value to the row, so a lookup takes O(log n): about 20 steps for a million rows.

The rest of this lesson is part of Pro

Pro unlocks every lesson with its animation, code challenge and quiz, plus every interview problem. ₹299 a month or ₹1,999 a year.

See Pro

Remember it, then prove it

Create a free account to save your progress, get spaced-repetition reviews of what you miss, and design real systems in the interview simulator.

Start free