FULL AI ANALYSIS

PostgreSQL VACUUM stalls on partitioned table during heavy insert bursts; autovacuum appears idle

Generated Oct 24, 2026, 9:21:01 AM

Analysis summary

Autovacuum stalls often come from long-running transactions that hold old snapshots (preventing cleanup), resource contention (IO saturation), or insufficient autovacuum worker capacity for many partitions. Partitioned tables amplify the problem because each partition needs attention and concurrent inserts keep new partitions busy. Diagnostics: check pg_stat_activity for long transactions, pg_stat_progress_vacuum for worker progress, and OS IO metrics. Recovery steps: identify and terminate/commit blockers, throttle or schedule inserts to allow vacuum, increase autovacuum worker settings for high-partition counts, and target vacuum on idle partitions first. Avoid VACUUM FULL on busy systems as it's more disruptive.

Possible causes

Long-lived open transactions (snapshot holders) prevent VACUUM from reclaiming tuples, making autovacuum effectively idle.

80%

Disk IO saturation from heavy insert workload causing vacuum worker IO to starve and make no progress.

60%

Insufficient autovacuum workers relative to many partitions; workers never reach all partitions in time.

45%

Autovacuum settings for recently created partitions are conservative (high thresholds) so autovacuum does not trigger timely.

40%

Suggested fixes

1

Diagnostic step 1

Check pg_stat_activity and pg_locks for open transactions that predate the inserts; if safe, ask owners to commit/close or terminate hung sessions.

2

Diagnostic step 2

Inspect pg_stat_progress_vacuum to see where workers are stuck and use pg_stat_io or iostat to check for IO saturation.

3

Diagnostic step 3

Temporarily throttle insert workers (reduce client concurrency or use traffic shaping) for a maintenance window to let vacuum catch up.

4

Diagnostic step 4

Increase autovacuum_max_workers and reduce autovacuum_vacuum_scale_factor for hot partitions, applied per-partition via ALTER TABLE SET (autovacuum_vacuum_scale_factor = 0.01).

5

Diagnostic step 5

If necessary, run manual VACUUM on cold partitions first and avoid immediate VACUUM FULL on live partitions; coordinate with app teams for low-traffic windows.