Indexes & EXPLAIN
Make queries fast, and see how the planner thinks.
Why some queries are fast
Without help, finding WHERE email = '…' means scanning every row (a sequential scan). An index is a sorted structure the planner can jump into — turning a full scan into a quick lookup:
CREATE INDEX books_genre_idx ON books (genre);
EXPLAIN shows the query plan the planner chose without running the query — Seq Scan vs Index Scan, with cost estimates:
EXPLAIN SELECT * FROM books WHERE genre = 'fiction';
Indexes speed reads but cost storage and slow writes, so you index the columns you filter and join on — not every column. (On a 10-row table the planner may still pick a seq scan; it's only worth an index when the table is large.)