Indexes
An index, usually a B-tree, lets the database find rows without scanning the whole table, like the index at the back of a book. Indexes speed up equality lookups, range queries and sorting on the indexed columns. They cost storage, and every insert, update and delete must also update each index, so write-heavy tables should carry few indexes.
A composite index on (a, b) is sorted by a first, then b: it helps queries filtering on a, or on a and b, but generally not on b alone (the leftmost-prefix rule). Put equality columns before range columns. Tools such as EXPLAIN show whether a query uses an index or falls back to a full scan.