PostgreSQL bulk INSERT throughput collapses on partitioned table after stats collector restart
Environment
PostgreSQL 14 primary on dedicated server (32 cores, 256GB RAM) hosting a monthly-partitioned table with daily partitions; bulk import jobs insert ~10M rows per hour into today's partition via COPY and INSERT FROM staging. Stats collector (pg_statistic) process restarted during maintenance last night.
Symptoms
Bulk imports that normally complete in ~30 minutes now take 3–4× longer, with CPU usage low, WAL write rate normal and I/O not saturated. Query planner for subsequent index maintenance shows sequential scans where index scans were expected, and autovacuum triggered more frequently.
Observations
EXPLAIN ANALYZE of a key SELECT used during import shows planner choosing a generic plan with higher estimated cost. pg_statistic shows low or zero n_distinct and histogram entries for several columns in the partition. pg_stat_activity shows autovacuum workers running ANALYZE on new partitions repeatedly. The stats collector was restarted during maintenance and its PID changed; last_analyze timestamps for partitions are older than expected and autoanalyze appears triggered now. VACUUM VERBOSE indicates low page visibility map usage.
Already attempted
Manually ran ANALYZE on the affected partition and re-ran the bulk import; import throughput returned to expected levels for that partition. Repeating the test for newly created partitions showed the problem recurred until ANALYZE is run. Checked autovacuum settings; autovacuum_vacuum_scale_factor and autovacuum_analyze_scale_factor set to defaults. Did not change any planner-related configuration parameters.
Question
Why did restarting the stats collector lead to dramatically slower bulk INSERTs on a partitioned table, and what safe configuration or process changes will avoid this regression without requiring manual ANALYZE after each maintenance?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Databases27% match
JDBC prepared statements on application server suddenly select a generic plan causing a 15× slowdown for partitioned table queries
Open0 answers - Databases26% match
PostgreSQL prepared statements pick a generic plan after ANALYZE on a partitioned table, causing 10× slower execution
Open0 answers - Databases25% match
PostgreSQL autovacuum ignores newly created partitions causing rapid bloat and slow queries on recent partitions
Open0 answers - Databases24% match
MongoDB primary stalls and throughput collapses when WiredTiger cache reaches high utilization during sustained bulk inserts
Open0 answers - Databases24% match
PostgreSQL 14: Rapid table bloat after nightly batch UPDATEs despite autovacuum enabled
Open0 answers