Re: Parallel heap vacuum

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, John Naylor <johncnaylorls(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Parallel heap vacuum
Date: 2026-07-17 17:03:00
Message-ID: CALj2ACUMbUrcYzzbdSoPgsv+3kFdkGovDZe6aP3e6XQCzFqy9g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Jul 21, 2025 at 4:49 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
>
> I don't think that can be the right solution. Vacuuming is a table-am specific
> operation and thus already happens within a table-am's own code. It would be
> rather wrong to have tableam.h indirected calls below heapam specific code.
>
> That is not to say you can't have callbacks or such, it just doesn't make
> sense for those callbacks to be at the level of tableam. If you want to make
> vacuumparallel support parallel table vacuuming for multiple table AMs (I'm
> somewhat doubtful that's a good idea), you could do that by having a
> vacuumparallel.c specific callback struct.

Thank you all for reviewing this work, and thank you Sawada-san for
the off-list discussion. I would like to continue the parallel heap
vacuum work for PG20. Attached are the v20 patches.

The main changes in this version:

1/ Moved the parallel-vacuum callbacks out of the table AM interface.
As suggested upthread, the access method now passes them to
vacuumparallel.c through a local callback struct, so the generic
parallel vacuum code no longer calls into the table AM.

2/ Condensed the patches into just 2. 0001 moves the heap scan state
from LVRelState to a new struct that each parallel worker fills
independently and the leader combines. 0002 adds support for parallel
heap vacuuming (to be more precise, phase 1 of vacuum, which scans
heap pages, prunes and freezes tuples, and collects dead tuple TIDs),
along with some tests.

3/ Reworded comments throughout for design clarity, consistent
terminology, and formatting.

As a next step I will go through the whole thread one more time to
address any remaining review comments or design issues, and will do
more testing and performance experiments.

Appreciate any thoughts. Thank you!

--
Bharath Rupireddy
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v20-0001-Introduce-LVScanData-for-lazy-heap-scan-state.patch application/x-patch 27.9 KB
v20-0002-Support-parallel-heap-vacuum-for-collecting-dead.patch application/x-patch 103.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-07-17 17:28:17 Re: Follow-up fixes for online wal_level change
Previous Message Sami Imseih 2026-07-17 16:58:40 Re: Add pg_stat_kind_info system view