Autovacuum of a large table takes too long Autovacuum of a large table takes too long postgresql postgresql

Autovacuum of a large table takes too long


run truncate in one session and leave it working, then open new connection and kill all other sessions with pg_terminate_backend(pid).Keep in mind

  • truncate will erase all your data from table
  • autovacuum is better to be on


This would help you. Try analyze in stages.


If auto vacuum is taking too long, it might actually be because you switched it off for a while.

The usual goal of routine vacuuming is to do standard VACUUMs often enough to avoid needing VACUUM FULL. The autovacuum daemon attempts to work this way, and in fact will never issue VACUUM FULL.

The solution to slow vacuum is to vacuum more often! Also note that settnig autovaccum to off may not switch it off completely.