10
Autovacuum Worker
Memory settings
autovacuum_work_mem = −1
(−1 means maintenance_work_mem = 64MB)
settings are applied to each worker process,
memory is allocated in full immediately
more memory reduces overprocessing of index pages
Monitoring
log_autovacuum_min_duration = 10min
pg_stat_progress_vacuum
In addition to settings that determine when and how autovacuum operates,
we can adjust the memory allocated to autovacuum worker processes.
By default, the memory is limited by the maintenance_work_mem
parameter, which affects not only autovacuum, but also all other
maintenance operations. Usually this parameter can be set to a sufficiently
high value, since there are not so many background processes. However,
the number of autovacuum worker processes (controlled by the
autovacuum_max_workers parameter) can be large, and memory is
allocated immediately (not by demand). For this reason, we can set a
separate limit for autovacuum worker processes using the
autovacuum_work_mem parameter.
As discussed in the Vacuuming lesson, the vacuum procedure can operate
with minimal memory. However, if a table has indexes, insufficient value can
lead to repeated scans of the same index pages, significantly slowing down
autovacuum. The goal is to determine a minimal amount of memory that
prevents repeated index scans.
For monitoring, we use log_autovacuum_min_duration parameter
(autovacuum operations that last longer than its value will be registered in
the server log), and the pg_stat_progress_vacuum view, which provides
real-time progress information.
It is important to note that increasing memory is often less effective than
lowering the vacuum threshold to reduce the amount of data processed per
operation.