Developer Productivity & Platform EngineeringPlaybook3 min readUpdated September 2026

Reading a Query Plan Before You Add an Index

A query gets slow, an engineer adds an index without checking the actual query plan, and the new index doesn't match how the planner would actually use it. Every write to that table now pays an extra index-maintenance cost, with zero read benefit to show for it.

Reading the query plan first, not guessing at what might help, is the difference between an index that actually gets used and one that just sits there as dead weight.

What EXPLAIN ANALYZE Actually Tells You

A query plan shows whether the database is doing a sequential scan across the whole table or an index scan targeting specific rows, the planner's estimated row count versus what it actually found, and where the actual time is being spent. A large gap between estimated and actual row counts usually points to stale table statistics, a separate problem an index alone won't fix.

Matching an Index to How the Query Actually Filters

A composite index's column order matters: put the most selective equality filter first, then range filters, then any columns used purely for sorting. The leftmost-prefix rule governs whether the planner can even use it at all: an index on two columns in a specific order doesn't help a query that only filters on the second column alone.

Why More Indexes Isn't Free

Every index adds write overhead, since it has to be updated on every insert, update, and delete that touches the indexed columns, along with its own storage cost. An index that your database's own usage counters mark as never touched by the planner is a strong candidate to drop, not to keep just in case someday it might be.

A Workflow for Adding an Index Safely

  • Run EXPLAIN ANALYZE on the actual slow query against representative data volume, not a nearly-empty development database where every query looks fast.
  • Build the index concurrently on a production table where that option exists, so the build itself doesn't lock out writes.
  • Re-run EXPLAIN ANALYZE after adding the index to confirm the planner is actually choosing to use it, since it sometimes decides not to.

When Automated Indexing Advisors Help and When They Don't

A managed database's automated index recommendation feature is a reasonable source of candidates to investigate, since it can surface a pattern a human hasn't noticed yet. It doesn't know your actual traffic growth trajectory or which queries matter most to your business the way a human reviewing the real query plan does, so treat its suggestions as a hypothesis worth verifying with EXPLAIN ANALYZE, not an instruction to apply automatically.

Watching Query Plans Change as Data Grows

A plan that made a sensible choice at a hundred thousand rows can make a completely different, worse choice at ten million, because the planner's cost model shifts with table size and the distribution of values in each column. An index that looked unnecessary early on can become genuinely necessary later, and one that helped early can stop mattering once a different access pattern dominates.

Re-run EXPLAIN ANALYZE on your highest-traffic queries periodically as tables grow, rather than treating an indexing decision made at launch as permanent. What was the right call for the data you had a year ago isn't automatically still the right call for the data you have now.

Tie this review to a natural trigger rather than an arbitrary calendar reminder: a table crossing an order of magnitude in row count, or a query that used to be fast showing up in a slow query log for the first time, are both better signals that it's time to look again than a fixed schedule that may or may not line up with when anything actually changed.

Keep a short note next to each nonobvious index explaining which query it was added for. Six months later, nobody remembers the reasoning behind an index with a generic name, and that missing context is exactly why teams end up afraid to drop anything, even things the usage counters clearly mark as dead weight.

Executive Capability Standard

What Good Looks Like

Good indexing practice means every index in production is backed by an EXPLAIN ANALYZE showing the planner actually uses it, and an index that isn't used gets dropped rather than kept just in case.

Building The Capability (5-Stage Skill Ladder)

1. Learn:Run EXPLAIN ANALYZE on your slowest known query against representative data and read what the planner is actually doing.
2. Do Manually:Manually review your database's index usage statistics for one table and flag anything that's never actually chosen by the planner.
3. Delegate:Assign one engineer to review any proposed new index against a real query plan before it ships to production.
4. Automate:Automate a recurring report of unused indexes so candidates for removal don't rely on someone remembering to check.
5. Buy:Bring in a database specialist to review indexing strategy on your highest-traffic tables before a major schema change.

How to Get Started

Frequently Asked Questions

Why isn't the planner using the new index I just added?

Check column order against the leftmost-prefix rule first; an index on two columns doesn't help a query filtering only on the second one. Also check table statistics: if they're stale, the planner's cost estimate can be wrong enough that it prefers a sequential scan even when an index scan would actually be faster.

How many indexes is too many on one table?

There's no fixed number; the real question is whether each index is actually used by real query patterns your database's own usage statistics confirm. An index the planner never chooses is pure write overhead with no offsetting benefit, and that's true whether it's the third index on the table or the fifteenth.

Should I trust my database's automated index suggestions?

Treat them as candidates worth investigating with EXPLAIN ANALYZE against your real queries, not as instructions to apply automatically. An automated advisor doesn't know your business priorities or growth trajectory, so a human reviewing the actual query plan is still the final check before adding an index to a production table.

About the numbers

This guide doesn't quote a sourced benchmark. Figures in it are estimates or general guidance, so check them against your own numbers.

Related Guides