From 91dc3d05c56b7587f94ac0220510d565d61557e0 Mon Sep 17 00:00:00 2001 From: Melanie Plageman Date: Sat, 6 Jan 2024 13:14:47 -0500 Subject: [PATCH v1 01/15] lazy_scan_prune tests tuple vis with GlobalVisTest One requirement for eventually combining the prune and freeze records, is that we must check during pruning if live tuples on the page are visible to everyone and thus, whether or not the page is all visible. We only consider opportunistically freezing tuples if the whole page is all visible and could be set all frozen. During pruning (in heap_page_prune()), we do not have access to VacuumCutoffs -- as on access pruning also calls heap_page_prune(). We do, however, have access to a GlobalVisState. This can be used to determine whether or not the tuple is visible to everyone. It also has the potential of being more up-to-date than VacuumCutoffs->OldestXmin. This commit simply modifies lazy_scan_prune() to use GlobalVisState instead of OldestXmin. Future commits will move the all_visible/all_frozen calculation into heap_page_prune(). --- src/backend/access/heap/vacuumlazy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 0fb3953513d..7428c83bdfd 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -1553,8 +1553,7 @@ lazy_scan_prune(LVRelState *vacrel, * that everyone sees it as committed? */ xmin = HeapTupleHeaderGetXmin(htup); - if (!TransactionIdPrecedes(xmin, - vacrel->cutoffs.OldestXmin)) + if (!GlobalVisTestIsRemovableXid(vacrel->vistest, xmin)) { all_visible = false; break; -- 2.37.2