CodeOath
← All posts
SQL65 min total · 16 parts

Understanding SQL Indexes and Query Performance

Contents — Part 15 of 16: A Practical Checklist
Part 15 of 16 · ~1 min

A Practical Checklist

  • Index columns that appear often in WHERE, JOIN, and ORDER BY clauses — not every column, and not defensively.
  • Put the most selective / most commonly filtered-alone column first in a composite index, unless queries always filter on a specific column together with others.
  • Avoid wrapping indexed columns in functions inside WHERE clauses; if you genuinely need to, consider a functional/expression index instead.
  • Consider a covering index for a small number of genuinely hot, latency-sensitive queries — not as a default for every query.
  • Prefer EXISTS over NOT IN for subqueries whose data could contain a NULL.
  • Confirm any performance assumption with an actual execution plan (EXPLAIN) rather than reasoning from the SQL text alone — real statistics on real data settle every debate in this reference.
  • Periodically check for unused indexes — most engines expose this — since they cost write performance for no read benefit.