Skip to main content

Indexes that match how you query

  • PHP
  • Performance
  • Architecture

Composite indexes are not free—order columns the way your WHERE and ORDER BY clauses read.

Before adding an index, capture the slow query and its parameters. EXPLAIN on production-like data beats guessing from local empty tables.

Put the most selective filtered columns first in composite indexes when they share a prefix scan. Covering indexes help read-heavy reporting paths but widen write cost.

Revisit indexes after major refactors; the query that needed a three-column index last year may be gone.