Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)

From: Alexey Makhmutov <a(dot)makhmutov(at)postgrespro(dot)ru>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Robert Haas <robertmhaas(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Date: 2026-04-06 14:30:51
Message-ID: ead2f110-c736-48f5-99e1-023dc9acbf0b@postgrespro.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Melanie,

Sorry for the late note for the already committed patch, but I have a
question on the last part of the 'heap_xlog_prune_freeze' function
related to the FSM update (it was committed in add323d -'Eliminate
XLOG_HEAP2_VISIBLE from vacuum phase III').

Currently it contains the following logic:

...
Size freespace = 0;
...
if (BufferIsValid(buffer))
{
if ((xlrec.flags & (XLHP_HAS_REDIRECTIONS |
XLHP_HAS_DEAD_ITEMS |
XLHP_HAS_NOW_UNUSED_ITEMS)) ||
(vmflags & VISIBILITYMAP_VALID_BITS))
freespace = PageGetHeapFreeSpace(BufferGetPage(buffer));
...
UnlockReleaseBuffer(buffer);
}
...
if (freespace > 0)
XLogRecordPageWithFreeSpace(rlocator, blkno, freespace);
...

My question is about the last check ('freespace > 0') - do we really
want to call 'XLogRecordPageWithFreeSpace' only if 'freespace' is
greater than 0? As I understand, the zero value is a perfectly valid
output of the 'PageGetHeapFreeSpace' call (i.e. page has no space or no
free line items while we mark all rows as frozen/visible), but with the
current implementation we will skip FSM update in such case. Maybe we
need to use additional flag (i.e. 'need_fsm_update'), set it before
calling 'PageGetHeapFreeSpace' and then check before the
'XLogRecordPageWithFreeSpace' invocation?

Thanks,
Alexey

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2026-04-06 14:30:58 Re: PG 19 release notes and authors
Previous Message Bruce Momjian 2026-04-06 14:29:57 Re: PG 19 release notes and authors