From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | autovacuum: recheck logic |
Date: | 2007-03-27 20:58:16 |
Message-ID: | 20070327205816.GA5999@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
Hi,
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
concurrently.
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"
Attachment | Content-Type | Size |
---|---|---|
autovacuum-recheck.patch | text/x-diff | 21.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2007-03-27 21:04:39 | Re: Arrays of Complex Types |
Previous Message | Magnus Hagander | 2007-03-27 20:38:40 | Re: [pgsql-patches] O_DIRECT support for Windows |