PostgreSQL autovacuum CPU spikes and accelerating table bloat after lowering autovacuum_vacuum_cost_delay
Environment
PostgreSQL 13 on Debian 11 VM, OLTP workload with frequent updates/deletes on several large partitioned tables; autovacuum_vacuum_cost_delay changed from 20ms down to 2–5ms across the cluster two days ago.
Symptoms
Unexpected CPU consumption by autovacuum workers (50–80% CPU on several cores), workload latency increases for application queries; reported table bloat on several large tables increasing over consecutive hours despite autovacuum activity.
Observations
postgres logs show frequent autovacuum launches and repeated vacuums on same partitions. iostat shows moderate IO but not saturated. Autovacuum workers sometimes conflict with hot transactions; autovacuum worker counts at max configured value.
Already attempted
Rolled autovacuum_vacuum_cost_delay back to 20ms on one replica (observed modest CPU drop there). Increased autovacuum_max_workers temporarily; no manual VACUUM FULL performed because of production constraints.
Question
How should autovacuum settings be tuned to reduce CPU spikes and bloat while keeping space reclaimed without causing heavy contention or excessive worker churn?
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
- Databases33% match
PostgreSQL 14: Rapid table bloat after nightly batch UPDATEs despite autovacuum enabled
Open0 answers - Databases31% match
PostgreSQL VACUUM stalls on partitioned table during heavy insert bursts; autovacuum appears idle
Open0 answers - Databases28% match
Logical backups hang waiting for locks when VACUUM FULL is running on large PostgreSQL tables
Open0 answers - Databases27% match
Autovacuum stalls and partition bloat due to lingering prepared transactions holding old snapshots in PostgreSQL 13
Open0 answers - Databases26% match
PostgreSQL replica falls behind and reports WAL streaming delay when frequent autovacuum runs on primary
Open0 answers