pgsql: Keep newest live XID up-to-date even if page not all-visible

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Keep newest live XID up-to-date even if page not all-visible
Date: 2026-03-24 19:39:17
Message-ID: E1w57au-001HZX-1N@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Keep newest live XID up-to-date even if page not all-visible

During pruning, we keep track of the newest xmin of live tuples on the
page visible to all running and future transactions so that we can use
it later as the snapshot conflict horizon when setting the VM if the
page turns out to be all-visible.

Previously, we stopped updating this value once we determined the page
was not all-visible. However, maintaining it even when the page is not
all-visible is inexpensive and makes the snapshot conflict horizon
calculation clearer. This guarantees it won't contain a stale value.

Since we'll keep it up to date all the time now anyway, there's no
reason not to maintain set_all_visible for on-access pruning. This will
allow us to set the VM on-access in the future.

Author: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/bqc4kh5midfn44gnjiqez3bjqv4zogydguvdn446riw45jcf3y%404ez66il7ebvk

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9ba3ec076a68b82d49fb4d0ea008205befd2292b

Modified Files
--------------
src/backend/access/heap/pruneheap.c | 138 +++++++++++++++--------------------
src/backend/access/heap/vacuumlazy.c | 30 ++++----
2 files changed, 73 insertions(+), 95 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2026-03-24 20:47:03 pgsql: get_memoize_path: Don't exit quickly when PGS_NESTLOOP_PLAIN is
Previous Message Melanie Plageman 2026-03-24 18:56:05 pgsql: Use GlobalVisState in vacuum to determine page level visibility