Re: Emit fewer vacuum records by reaping removable tuples during pruning - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Emit fewer vacuum records by reaping removable tuples during pruning
Date
Msg-id CA+TgmoZ7fRVC6UayHp85uOJvfxozVbM42inv=Fmmhh4Wv-YsuQ@mail.gmail.com
Whole thread Raw
In response to Re: Emit fewer vacuum records by reaping removable tuples during pruning  (Peter Geoghegan <pg@bowt.ie>)
Responses Re: Emit fewer vacuum records by reaping removable tuples during pruning
List pgsql-hackers
On Fri, Jan 12, 2024 at 11:50 AM Peter Geoghegan <pg@bowt.ie> wrote:
> Why do you think that lazy_scan_prune() and lazy_scan_noprune() have
> different ideas about whether to update the FSM or not?

When lazy_scan_prune() is called, we call RecordPageWithFreeSpace if
vacrel->nindexes == 0 && prunestate.has_lpdead_items. See the code
near the comment that begins "Consider the need to do page-at-a-time
heap vacuuming".

When lazy_scan_noprune() is called, whether we call
RecordPageWithFreeSpace depends on the output parameter
recordfreespace. That is set to true whenever vacrel->nindexes == 0 ||
lpdead_items == 0. See the code near the comment that begins "Save any
LP_DEAD items".

The case where I thought there was a behavior difference is when
vacrel->nindexes == 0 and lpdead_items == 0 and thus
prunestate.has_lpdead_items is false. But now I see (from Melanie's
email) that this isn't really true, because in that case we fall
through to the logic that we use when indexes are present, giving us a
second chance to call RecordPageWithFreeSpace(), which we take when
(prunestate.has_lpdead_items && vacrel->do_index_vacuuming) comes out
false, as it always does in the scenario that I postulated.

P.S. to Melanie: I'll respond to your further emails next but I wanted
to respond to this one from Peter first so he didn't think I was
rudely ignoring him. :-)

P.P.S. to everyone: Yikes, this logic is really confusing.

--
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Nazir Bilal Yavuz
Date:
Subject: Re: speed up a logical replica setup
Next
From: Melanie Plageman
Date:
Subject: Re: Emit fewer vacuum records by reaping removable tuples during pruning