Indexes

RequiredRequired

Juan Camilo ZúñigaBackend & data developer

An index is a sorted copy of one or more columns that lets the database find rows without reading the whole table. It speeds up reads and costs space plus a little time on every write.

How to use them

  • Index the columns you filter and join on, starting with the most selective.
  • Read the plan with EXPLAIN ANALYZE before and after adding one; trust the plan, not intuition.
  • A composite index on (a, b) helps queries on a or on a and b, but not on b alone.