Re: mysterious nbtree.c comment

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: mysterious nbtree.c comment
Date: 2006-07-03 21:42:43
Message-ID: 1151962964.2479.319.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2006-07-03 at 16:34 -0400, Greg Stark wrote:
> In nbtree.c there's a path that calls btvacuumscan to gather statistics if
> there aren't already statistics. I'm not exactly clear how this code path is
> reached but that's not my question.

VACUUM calls access/index/index_vacuum_cleanup() which is part of the
btree index access method API. In the case of a btree index this is a
function pointer to access/nbtree/btvacuumcleanup()

That is important to your question.

> There's a comment that "there's no need to
> go through all the vacuum-cycle-ID pushups" in this case because no deletions
> are being performed.
>
> I don't see how the lack of deletions is relevant to needing vacuum-cycle-ID.
> AFAICT there's still a risk that someone will come along and do a page split
> underneath this scan and if the page is to the left of the scan it will be
> missed.

Read the comments in btvacuumscan. It is only important to scan all the
pages of an index when deleting leaf items.

The btvacuumscan called from btvacuumcleanup only gets called when stats
are NULL. That only happens when the VACUUM returns no rows for cleanup,
so the scan need only perform one of its three functions: remove pages
already marked as deleted that can now be recycled into the FSM. You're
right - it will be missed but its not crucial to the scan when called in
that way since we'll pick it up next time around.

--
Simon Riggs
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2006-07-03 22:55:43 buildfarm stats
Previous Message Greg Stark 2006-07-03 20:34:46 mysterious nbtree.c comment