§ GARDEN · SQL · CLASS OPEN
NODE FILE · ENTRY
Indexing Strategy for Real Workloads
FILED UNDER · SQL
①Read
②Meta
When to add an index, what kind to choose, and how to read EXPLAIN plans to verify your assumptions.
Indexes are the single most impactful performance lever in any database. A missing index turns a millisecond query into a multi-second table scan. But indexes aren't free — they slow down writes, consume storage, and can mislead the query planner if poorly designed.
Reading EXPLAIN Output
Always verify with EXPLAIN ANALYZE. Look for Seq Scan on large tables — that's usually the problem. Check the estimated vs. actual row counts — large discrepancies mean stale statistics. A good composite index follows the 'equality first, range last' rule: columns with = conditions go first, columns with range conditions go last.
DTNRWORKSHOP ARMAMENTSSN 2012.OTT.0176