Re: visibilitymap_count() at the end of vacuum

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: visibilitymap_count() at the end of vacuum
Date: 2012-12-03 19:02:40
Message-ID: CA+U5nMK4qLg0ct01q1EmiJO3R2N6tH8msV=XAw9By9Y79rBGEQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 3 December 2012 18:20, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> Hi,
>
> On 2012-12-03 23:44:36 +0530, Pavan Deolasee wrote:
>> I wonder if we really need to make another pass over the entire visibility
>> map to count the number of all-visible pages at the end of the vacuum. The
>> code that I'm looking at is in src/backend/commands/vacuumlazy.c:
>>
>> 247 new_rel_allvisible = visibilitymap_count(onerel);
>> 248 if (new_rel_allvisible > new_rel_pages)
>> 249 new_rel_allvisible = new_rel_pages;
>>
>> We would have just scanned every bit of the visibility map and can remember
>> information about the number of all-visible pages in vacrelstats, just like
>> many other statistical information that we track and update the end of the
>> vacuum. Sure, there might be some more updates to the VM, especially a few
>> bits may get cleared while we are vacuuming the table, but that can happen
>> even while we are recounting at the end. AFAICS we can deal with that much
>> staleness of the data.
>
> A full-table vacuum can take a *long* (as in days) time, so I think
> recounting makes sense. And normally the cost is pretty small, so I
> don't see a problem in this.
>
> Why change it?

There's another reason for doing it this way: if VACUUM sets
everything as all visible, but during the VACUUM that state is quickly
reset by others, it would be a mistake not to allow for that. We want
a realistic value not a best possible case.

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Asif Rehman 2012-12-03 19:15:27 Re: why can't plpgsql return a row-expression?
Previous Message Simon Riggs 2012-12-03 18:58:45 Re: Visibility map page pinned for too long ?