2025-06-08 · Haruto Watanabe

Reading a query plan with a hypothesis, not hope

Reading a query plan with a hypothesis, not hope

Start by stating the business question in plain language. Translate that to the smallest query that reproduces the issue. Capture the plan, then write one sentence: “I believe the planner chose X because Y.” If Y references cost estimates, note the statistics targets.

Change one variable at a time: enable_seqscan off temporarily in a session to see alternatives—not as a fix, as a probe. Adjust work_mem only with a hypothesis about spills. Students often discover that their “mystery regression” is a statistics target that has not caught up with a bulk load.

We end the module with a memo graded on clarity, not speedups. A clear wrong theory is more valuable than a vague right tweak—you can falsify it quickly.

Tags: query plans, postgresql, methodology

← Back to blog