EXPLAIN Best Practices
Rigorous plan capture turns guesswork into reviewable evidence. Use this list when triaging slow queries or approving index PRs on PostgreSQL 18.4.
Search across all documentation pages
Rigorous plan capture turns guesswork into reviewable evidence. Use this list when triaging slow queries or approving index PRs on PostgreSQL 18.4.
EXPLAIN (ANALYZE, BUFFERS, SETTINGS) output in tickets.ANALYZE on touched tables before comparing plans. Fair cardinality baseline.EXPLAIN (ANALYZE, BUFFERS, SETTINGS) for investigations. Timings, I/O, and GUC context.search_path, and pool mode (session vs transaction). Plans differ by session shape.actual time node first. Optimize the real bottleneck.rows= estimates to actual rows= on driving nodes. Flags stats or correlation bugs.external merge Disk, hash batches > 1). Memory tuning signal.Heap Fetches on index-only attempts. Visibility map may need vacuum.EXPLAIN ANALYZE on destructive SQL without ROLLBACK. ANALYZE executes the statement.statement_timeout. Protect shared primaries.pg_stat_statements totals. Confirm the query matters at scale.Stack versions: This page was written for PostgreSQL 18.4 (stable 18, maintenance 17), pgvector 0.8+, PgBouncer 1.x, Patroni 3.x, and PostGIS 3.5+.
Reviewed by Chris St. John·Last updated Jul 19, 2026