autovacuum and TOAST tables

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: autovacuum and TOAST tables
Date: 2008-08-08 16:58:09
Message-ID: 20080808165809.GB3800@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Here's a patch to make autovacuum process TOAST tables separately from
main tables.

The most important change is that when called from autovac, vacuum does
not process the TOAST table at all. It will only do so when the stats
for the TOAST table say that it needs vacuuming. (A user-invoked vacuum
still processes TOAST tables normally.)

Per previous discussion, the autovac code is now doing two passes over
pg_class.

There's two things I'm not happy about in this patch:

1. it uses a List to keep the mapping of heap<->toast Oids. This is
needed to be able to fetch the main rel's pg_autovacuum entry to process
the toast table. This incurs in O(n^2) behavior.

2. the "expected relkind" business is gone; it's not easy to pass the
correct relkind down from autovac, and at the same time have a
reasonable thing to pass down from user-invoked vacuum. Right now what
the patch does is check that the rel to vacuum is either
RELKIND_RELATION or _TOASTVALUE.

(I admit that my unhappiness about the second is mild, though.)

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment Content-Type Size
autovac-notoast-3.patch text/x-diff 23.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2008-08-08 17:01:28 Re: Proposal of SE-PostgreSQL patches [try#2]
Previous Message Josh Berkus 2008-08-08 16:52:13 Re: CommitFest July Over