Re: optimizing vacuum truncation scans - Mailing list pgsql-hackers

From Haribabu Kommi
Subject Re: optimizing vacuum truncation scans
Date
Msg-id CAJrrPGcvXQjUDc20pBqz4BK4S185ABXsuDQsByJZWa=Sht=kKw@mail.gmail.com
Whole thread Raw
In response to Re: optimizing vacuum truncation scans  (Jeff Janes <jeff.janes@gmail.com>)
Responses Re: optimizing vacuum truncation scans
List pgsql-hackers
On Mon, Jun 29, 2015 at 3:54 PM, Jeff Janes <jeff.janes@gmail.com> wrote:
>
> Attached is a patch that implements the vm scan for truncation.  It
> introduces a variable to hold the last blkno which was skipped during the
> forward portion.  Any blocks after both this blkno and after the last
> inspected nonempty page (which the code is already tracking) must have been
> observed to be empty by the current vacuum.  Any other process rendering the
> page nonempty are required to clear the vm bit, and no other process can set
> the bit again during the vacuum's lifetime.  So if the bit is still set, the
> page is still empty without needing to inspect it.

The patch looks good and it improves the vacuum truncation speed significantly.

> There is still the case of pages which had their visibility bit set by a
> prior vacuum and then were not inspected by the current one.  Once the
> truncation scan runs into these pages, it falls back to the previous
> behavior of reading block by block backwards.  So there could still be
> reason to optimize that fallback using forward-reading prefetch.

The case, I didn't understand is that, how the current vacuum misses
the page which
was set by the prior vacuum?

The page should be counted either in skipped_pages or in
nonempty_pages. Is it possible
that a page doesn't comes under these two categories and it is not empty also?

If the above doesn't exist, then we can directly truncate the relation
from the highest block
number of either nonempty_pages or skipped_pages to till the end of
the relation.

Regards,
Hari Babu
Fujitsu Australia



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: obsolete comment in elog.h
Next
From: Sawada Masahiko
Date:
Subject: Re: Freeze avoidance of very large table.