Skip to content

Commit e918e79

Browse files
melanieplagemanCommitfest Bot
authored andcommitted
Unset all_visible sooner if not freezing
In the prune/freeze path, we currently delay clearing all_visible and all_frozen in the presence of dead items to allow opportunistic freezing. However, if no freezing will be attempted, there’s no need to delay. Clearing the flags earlier avoids extra bookkeeping in heap_prune_record_unchanged_lp_normal(). This currently has no runtime effect because all callers that consider setting the VM also prepare freeze plans, but upcoming changes will allow on-access pruning to set the VM without freezing. The extra bookkeeping was noticeable in a profile of on-access VM setting.
1 parent 03d00a9 commit e918e79

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/access/heap/pruneheap.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,8 +1483,11 @@ heap_prune_record_dead(PruneState *prstate, OffsetNumber offnum,
14831483

14841484
/*
14851485
* Deliberately delay unsetting all_visible until later during pruning.
1486-
* Removable dead tuples shouldn't preclude freezing the page.
1486+
* Removable dead tuples shouldn't preclude freezing the page. If we won't
1487+
* attempt freezing, just unset all-visible now, though.
14871488
*/
1489+
if (!prstate->attempt_freeze)
1490+
prstate->all_visible = prstate->all_frozen = false;
14881491

14891492
/* Record the dead offset for vacuum */
14901493
prstate->deadoffsets[prstate->lpdead_items++] = offnum;
@@ -1739,8 +1742,11 @@ heap_prune_record_unchanged_lp_dead(Page page, PruneState *prstate, OffsetNumber
17391742
* Similarly, don't unset all_visible until later, at the end of
17401743
* heap_page_prune_and_freeze(). This will allow us to attempt to freeze
17411744
* the page after pruning. As long as we unset it before updating the
1742-
* visibility map, this will be correct.
1745+
* visibility map, this will be correct. If we won't attempt freezing,
1746+
* though, just unset all-visible now.
17431747
*/
1748+
if (!prstate->attempt_freeze)
1749+
prstate->all_visible = prstate->all_frozen = false;
17441750

17451751
/* Record the dead offset for vacuum */
17461752
prstate->deadoffsets[prstate->lpdead_items++] = offnum;

0 commit comments

Comments
 (0)