Database Index
A lookup structure that lets the database find rows without scanning the whole table.
A database index is an auxiliary data structure (usually a B-tree) that lets the database jump straight to matching rows instead of scanning every row. It makes reads on the indexed column fast — at the cost of extra storage and slower writes.
Worked example: without an index, WHERE email = ? scans all N rows (O(N)); with a B-tree index on email it is roughly O(log N) — the difference between milliseconds and seconds at scale. Gotcha: every index must be updated on each write, so over-indexing slows inserts and wastes space; and an index only helps if the query’s filter and sort match its columns and their order (a composite index on (a, b) helps WHERE a=? but not WHERE b=? alone).