Re: [PATCHES] smartvacuum() instead of autovacuum

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: "Jim C(dot) Nasby" <jim(at)nasby(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hitoshi Harada <hitoshi_harada(at)forcia(dot)com>, "'Peter Eisentraut'" <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] smartvacuum() instead of autovacuum
Date: 2006-10-24 01:22:50
Message-ID: 20061024012250.GA26593@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Jim C. Nasby wrote:
> On Mon, Oct 23, 2006 at 03:08:03PM -0400, Tom Lane wrote:
> > "Jim C. Nasby" <jim(at)nasby(dot)net> writes:
> > > The only case I can think of where autovac might not work as well as
> > > smartvacuum would be if you had a lot of databases in the cluster, since
> > > autovacuum will only vacuum one database at a time.
> >
> > It's conceivable that it'd make sense to allow multiple autovac
> > processes running in parallel. (The infrastructure part of this is easy
> > enough, the hard part is keeping them from all deciding to vacuum the
> > same table.)
>
> It might be worth creating a generic framework that prevents multiple
> vacuums from hitting a table at once, autovac or not.

That one is easy, because vacuum gets a lock on the affected table that
conflicts with itself. The problem is that the second vacuum would
actually wait for the first to finish.

A naive idea is to use ConditionalLockAcquire, and if it fails just skip
the table.

> > One reason we have not done that already is the thought that multiple
> > vacuum processes would suck too much I/O to be reasonable. Now you
> > could dial back their resource demands with the cost-delay settings,
> > but it's not clear that ten autovacs running at one-tenth speed are
> > better than one autovac using all the cycles you can spare. Usually
> > I think it's best if a vacuum transaction finishes as fast as it can.

In the scenario where one table is huge and another is very small, it
can certainly be useful to vacuum the small table several times while
the huge one has only been vacuumed once. For that you definitively
need the ability to run parallel vacuums.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2006-10-24 02:03:07 Bug related to out of memory condition
Previous Message Jim C. Nasby 2006-10-23 23:08:55 Re: [PATCHES] smartvacuum() instead of autovacuum

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-10-24 05:58:54 Re: BUG #2712: could not fsync segment: Permission
Previous Message Jim C. Nasby 2006-10-23 23:08:55 Re: [PATCHES] smartvacuum() instead of autovacuum