A page becomes slow and the team opens a PostgreSQL plan. The numbers look precise, but the conclusion sometimes arrives too quickly: add an index, or blame the disk. EXPLAIN is an investigation tool, not an automatic diagnosis. It works best when the reader has a specific question.

This analysis uses PostgreSQL 18 documentation. It does not present the version as a release from this week, and it is not based on a benchmark performed by our newsroom.

Separate predictions from execution

The EXPLAIN reference explains that ANALYZE executes the statement. That matters particularly for commands that modify data. In PostgreSQL 18, buffer information is included automatically with ANALYZE.

An estimated cost is not milliseconds. A mismatch between estimated and observed rows is also different from execution time. The plan-reading chapter helps keep those observations separate.

For a controlled experiment on an existing demonstration table:

EXPLAIN (ANALYZE, BUFFERS, TIMING OFF)
SELECT id
FROM demo_events
WHERE created_at >= TIMESTAMP '2026-10-01 00:00:00';

Adapt the names to your test data. Even a read can be expensive. Begin outside production with a representative dataset and a time limit appropriate to the environment.

Do not overinterpret buffer counters

shared hit records a block found in PostgreSQL's buffer cache. shared read records a block read into it; that alone does not prove every read reached physical storage rather than an operating-system cache.

A parent node's counters include its children. Adding every line can therefore count work more than once. Decide which level you are observing before comparing totals.

Keep the original question visible. Are you investigating an unnecessarily broad scan, different behaviour for different parameters, or a problem that occurs only under load? Those hypotheses need different evidence.

Compare comparable situations

We recommend retaining the statement, parameters, version and measurement context. A plan without that context becomes difficult to interpret a few days later.

Do not declare success after one slow run followed by one fast run. The difference deserves investigation, not automatic attribution to the latest code change. Repeat under controlled conditions and record what changed.

Apply the same caution when an index improves one isolated case. Define the other access patterns and write workload to examine before generalising. A local improvement is not enough to establish the overall trade-off.

The plan is not the entire user experience

The documentation notes that costs such as transmitting results to the client are not captured by the plan's estimated cost. An application can remain slow even when the observed SQL work is brief.

Our suggested method is to connect the plan with an application trace: time before execution, result retrieval and subsequent processing. That avoids looking for a networking problem inside a buffer counter.

A good investigation ends with a testable hypothesis and a saved comparison, not just an impressive screenshot. Our article on preparing a DuckDB migration applies the same principle to representative test data and repeatable checks.

Cover image: generated illustration; the displayed plan is not a real measurement.