Statistics Best Practices
Planner quality depends on fresh statistics. Treat ANALYZE as part of every data migration and performance review on PostgreSQL 18.4.
Search across all documentation pages
Planner quality depends on fresh statistics. Treat ANALYZE as part of every data migration and performance review on PostgreSQL 18.4.
EXPLAIN estimate vs actual row checks.ANALYZE after bulk COPY, delete purges, or backfills. Autoanalyze may lag hours.CREATE INDEX CONCURRENTLY on huge tables. Confirm planner picks it.n_mod_since_analyze on hot tables. Alert before plans rot.STATISTICS target only on proven skew columns. Not globally by default.date_trunc, lower where indexed.pg_stats and EXPLAIN before/after. Prove estimate fixes.CREATE STATISTICS is schema.random_page_cost matters.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