]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Simplify visibility check in heap_page_would_be_all_visible()
authorMelanie Plageman <melanieplageman@gmail.com>
Thu, 26 Feb 2026 20:33:36 +0000 (15:33 -0500)
committerMelanie Plageman <melanieplageman@gmail.com>
Thu, 26 Feb 2026 20:41:45 +0000 (15:41 -0500)
heap_page_would_be_all_visible() does not need to distinguish between
HEAPTUPLE_RECENTLY_DEAD and HEAPTUPLE_DEAD tuples: any tuple in a state
other than HEAPTUPLE_LIVE means the page is not all-visible and
heap_page_would_be_all_visible() returns false.

Given that, calling HeapTupleSatisfiesVacuum() is unnecessary, since it
performs extra work to distinguish between dead and recently dead tuples
using OldestXmin. Replace it with the more minimal
HeapTupleSatisfiesVacuumHorizon().

Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CALdSSPjvhGXihT_9f-GJabYU%3D_PjrFDUxYaURuTbfLyQM6TErg%40mail.gmail.com

src/backend/access/heap/vacuumlazy.c

index 4040483ed650b63941373d3f84b5668c1f49e61a..dcbaf49401bf5a5ed6c4d1b06c4b24d8b878537c 100644 (file)
@@ -3739,6 +3739,7 @@ heap_page_would_be_all_visible(Relation rel, Buffer buf,
        {
                ItemId          itemid;
                HeapTupleData tuple;
+               TransactionId dead_after;
 
                /*
                 * Set the offset number so that we can display it along with any
@@ -3778,7 +3779,7 @@ heap_page_would_be_all_visible(Relation rel, Buffer buf,
 
                /* Visibility checks may do IO or allocate memory */
                Assert(CritSectionCount == 0);
-               switch (HeapTupleSatisfiesVacuum(&tuple, OldestXmin, buf))
+               switch (HeapTupleSatisfiesVacuumHorizon(&tuple, buf, &dead_after))
                {
                        case HEAPTUPLE_LIVE:
                                {