With no index, the database reads row one, then row two.
It keeps going through all 10 million rows to be sure.
After a long wait, the one matching row is found.
An index is a sorted list that points to rows.
It turns reading every row into jumping to one.
It costs disk space and makes writes a little slower.
Reach for it when
When a slow query hunts one email among 10 million users, or sorts by a column. Tiny tables do not need one.
The catch
Every new user row must also update each index, so ten indexes on a busy table slow writes and eat disk.
Say it in an interview“I would index the columns used in frequent lookups, joins and sorts. I would accept slower writes and extra storage, and avoid indexing everything.”