PostgreSQL

EXPLAIN without ANALYZE may not reflect actual slow query execution

info
performanceUpdated Mar 4, 2026
Technologies:
How to detect:

Using EXPLAIN without ANALYZE only shows the planning phase and intended execution plan, not what actually happened during slow query execution. This can lead to incorrect diagnosis because it shows estimated costs and row counts rather than actual runtime behavior. The document states EXPLAIN without ANALYZE 'only represents what Postgres intends to do, not what was actually slow/fast during execution'.

Recommended action:

Always use EXPLAIN (ANALYZE) or EXPLAIN (ANALYZE, BUFFERS) for investigating slow queries in production. If the query overhead is too high to run in production, use auto_explain.log_analyze to automatically capture plans of slow queries as they occur. Avoid making optimization decisions based solely on EXPLAIN without ANALYZE, as estimated row counts and costs may differ significantly from actual execution.