Re: Why doesn't Vacuum FULL update the VM

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, vik(at)postgresfriends(dot)org
Subject: Re: Why doesn't Vacuum FULL update the VM
Date: 2023-09-03 20:48:15
Message-ID: CAAKRu_YrLE6m5zCj8niukKdtwhbk0U2yORDbevavjcWgN21OQg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 1, 2023 at 8:38 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
>
> On Fri, Sep 1, 2023 at 12:34 PM Melanie Plageman
> <melanieplageman(at)gmail(dot)com> wrote:
> > I don't see why the visibility map shouldn't be updated so that all of
> > the pages show all visible and all frozen for this relation after the
> > vacuum full.
>
> There was a similar issue with COPY FREEZE. It was fixed relatively
> recently -- see commit 7db0cd21.

Thanks for digging that up for me!

My first thought after looking a bit at the vacuum full/cluster code
is that we could add an all_visible flag to the RewriteState and set
it to false in heapam_relation_copy_for_cluster() in roughly the same
cases as heap_page_is_all_visible(), then, if rwstate->all_visible is
true in raw_heap_insert(), when we need to advance to the next block,
we set the page all visible and update the VM. Either way, we reset
all_visible to true since we are advancing to the next block.

I wrote a rough outline of that idea in the attached patches. It
doesn't emit WAL for the VM update or handle toast tables or anything
(it is just a rough sketch), but I just wondered if this was in the
right direction.

- Melanie

Attachment Content-Type Size
v0-0003-set-all_visible-in-VM-vac-full.patch text/x-patch 3.9 KB
v0-0001-Extern-RewriteStateData.patch text/x-patch 4.1 KB
v0-0002-VM-update-for-a-heap-block-not-in-SB.patch text/x-patch 2.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2023-09-04 00:00:00 Re: Cleaning up array_in()
Previous Message Pavel Stehule 2023-09-03 18:58:09 Re: proposal: psql: show current user in prompt