Capture query → Inspect plan → Test one change

What does EXPLAIN tell you?

EXPLAIN displays the plan PostgreSQL intends to use. EXPLAIN ANALYZE also executes the statement and reports observed behaviour. Planner costs are estimates in planner units; actual timings are milliseconds, so the two numbers are not directly interchangeable. Read PostgreSQL's plan-reading guide.

Because the analysed statement runs, treat write queries carefully. Do not use a production write as a casual performance experiment. Prefer a controlled environment with representative data and a clear recovery plan.

Start with the slow user action

Our recommendation is to capture the query behind a specific symptom: a delayed search, a slow export, or a list that stalls on later pages. Preserve the parameters, returned row count, and timing context. A hand-written query with a different filter may produce a reassuring plan that says little about the actual problem.

Inspect the plan from the leaves upward. Look at how many rows each step is expected to produce, where filtering happens, and which steps repeat. Compare observations against the workload rather than treating an index scan as an automatic success.

Change one thing you can explain

Before adding an index, write a hypothesis in one sentence. For example: the application repeatedly filters a large relation by the same narrow key, and the current plan examines far more rows than it returns.

Then test the proposed change with the same query and data conditions. Check other important operations too. An improvement to one read path is not a complete assessment of storage or write overhead.

Record the decision

Keep the query, plan, data size, environment, and before-and-after observations together. If the result is inconclusive, say so and identify the missing evidence. This small decision record makes it easier to revisit the choice after data distribution or traffic changes.

The goal is an explainable response to a measured problem. Adding several indexes until a development query feels fast makes the next investigation harder.

Source review: 15 November 2026. This is an editorial guide based on the linked documentation, not a report of client results.