J
jeremy
Text
PostgreSQL Autoanalyze and Stale Statistics
Article: PostgreSQL Autoanalyze and Stale Statistics
The planner chooses between a scan and an index from statistics that autovacuum refreshes on a schedule, so right after you import a million rows, restore a dump, or create a table in a migration, those statistics still describe the old, empty table. The result is a plan built for ten rows running against ten million. A single ANALYZE tablename after the load — and in a restored test database before you benchmark anything — removes an entire class of mysterious slowness.
Article: PostgreSQL Autoanalyze and Stale Statistics