autovacuum_naptime docs

From: Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com>
To: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: autovacuum_naptime docs
Date: 2023-04-05 21:19:52
Message-ID: CAOtHd0A0d-dtqFNzE4LwyyUiPF5+B0CLxPJ8M1gka1E6HB0Z3w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Some colleagues and I were looking at the autovacuum_naptime
documentation recently, and we were confused about the exact mechanism
at work here:

>Specifies the minimum delay between autovacuum runs on any given database. In each round the daemon examines the database and issues VACUUM and ANALYZE commands as needed for tables in that database. If this value is specified without units, it is taken as seconds. The default is one minute (1min). This parameter can only be set in the postgresql.conf file or on the server command line.

The Routine Vacuuming section has some additional info on this:

>The “autovacuum daemon” actually consists of multiple processes. There is a persistent daemon process, called the autovacuum launcher, which is in charge of starting autovacuum worker processes for all databases. The launcher will distribute the work across time, attempting to start one worker within each database every autovacuum_naptime seconds. (Therefore, if the installation has N databases, a new worker will be launched every autovacuum_naptime/N seconds.) A maximum of autovacuum_max_workers worker processes are allowed to run at the same time. If there are more than autovacuum_max_workers databases to be processed, the next database will be processed as soon as the first worker finishes. Each worker process will check each table within its database and execute VACUUM and/or ANALYZE as needed. log_autovacuum_min_duration can be set to monitor autovacuum workers' activity.

This is clearer, but it still elides some important details.

We found a post from Robert Haas [1] that explains this in more
detail, and the documentation quoted above is consistent with this,
but I think the setting docs especially could still be improved:

1. The documentation doesn't talk about the behavior of additional
workers launched in the same database. Technically it doesn't
contradict that behavior, but it's not clear that that's what should
be inferred, and this seems fairly important.

2. The setting documentation doesn't talk about the interaction with
autovacuum_max_workers, i.e., what happens when all workers are busy.
The Routine Vacuuming section addresses it, but maybe something like
"Specifies the delay between autovacuum runs on any given database if
a vacuum worker is available." would be clearer?

3. The docs say "...between autovacuum runs...," but "In each
round..." I assume a round is the same thing as a run here, so maybe
using the same word would be clearer?

Thoughts?

Thanks,
Maciek

[1]: http://rhaas.blogspot.com/2019/02/tuning-autovacuumnaptime.html

Browse pgsql-docs by date

  From Date Subject
Next Message Devrim Gündüz 2023-04-06 10:41:08 doc build error on Fedora 38
Previous Message Jiri Verunek 2023-04-05 11:18:12 Re: Bug in the documentation - to_tsquery( 'postgres:*' );