This is the first non-trivial patch to autovacuum multiple workers.
This patch that adds the "recheck" logic to autovacuum worker. With
this, the worker first builds its table list and then rechecks pgstat
before vacuuming each table to verify that no one has vacuumed the table
in the meantime, before vacuuming it.
In the current autovacuum world this only means that a worker will not
vacuum a table that a user has vacuumed manually. As discussed, it will
be much more useful as soon as multiple workers are running
To do this, I separated the task of calculating autovacuum parameters
(freeze_min_age, vacuum cost limit and delay, etc) from the autovac
equation calculation (freeze_max_age, pg_class.reltuples, etc).
We now keep track of three lists at the initial pg_class scan:
1. tables that need vacuum or analyze, per equations
2. tables not in (1) that have toast tables
3. toast tables that need vacuum
Then we append those tables in (2) whose toast tables are in (3), to the
(1) list. The rest are discarded. So when we need to do the
rechecking, we need to process only those tables that actually needed
vacuuming. With the previous coding, we would end up rechecking almost
all tables every time (to be exact, all tables that have a toast table).
The autovacuum parameters are only calculated in the second pass (the
rechecking). The first pass only yields boolean parameters.
Unless there are objections I'll apply this tomorrow.
Alvaro Herrera http://www.PlanetPostgreSQL.org
"La naturaleza, tan frágil, tan expuesta a la muerte... y tan viva"
pgsql-patches by date
|Next:||From: Andrew Dunstan||Date: 2007-03-27 21:04:39|
|Subject: Re: Arrays of Complex Types|
|Previous:||From: Magnus Hagander||Date: 2007-03-27 20:38:40|
|Subject: Re: [pgsql-patches] O_DIRECT support for Windows|