3

I have a few large tables that take days to autovacuum, sometimes resulting in poor performance until the vacuum finishes. Most of the recommendations I've seen mention doing a manual VACUUM during off-hours so that the autovacuum VACUUMs have less work to do, but if autovacuum takes days to finish is there any way to squeeze a manual VACUUM in (given a 24-hour peak activity cycle)?

I assume a manual VACUUM would still take days to finish? Or is my assumption incorrect?


Related: Do the different "types" of autovacuum have different performance characteristics?

4

"Sort-of".

Automatic VACUUM may run at a lower intensity than manual vacuum, so it pauses longer between each batch. autovacuum_vacuum_cost_delay may be set differently to vacuum_cost_delay; by default there is no delay on manual vacuum, only on autovacuum.

Autovacuum also works harder to avoid blocking concurrent queries and will abort its work if another query tries to take a lock that would conflict with vacuum. Depending on the vacuum phase this may not actually slow it down much, or it might throw away substantial work. The first phase heap sweep marking dead tuples and setting the visibility map doesn't care much if it's aborted part-way, though it might cause a subsequent vacuum to repeat some of the reads. It's much more expensive when we're updating indexes, but that's done in batches to reduce the amount of work lost if a vacuum is canceled.

See autovacuum configuration for the relevant parameters, most notably autovacuum_vacuum_cost_delay. Note that this differs from the vacuum_cost_delay setting used by manual vacuum.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.