Why a query gets slow

Without an index, finding rows means reading every row. At a thousand rows nobody notices. At a million, the same query takes seconds, and the symptom shows up as a slow page rather than a slow database.

Which columns to index

Index what you filter, join and sort on — not everything. Every index speeds reads and slows writes, and an index nobody uses is pure cost.

Composite indexes and order

In a composite index the column order matters: an index on (status, created_at) helps a query filtering status and sorting by date, but does little for one filtering only by date. Read the query first, then design the index.