pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Melanie Plageman <melanieplageman@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow on-access pruning to set pages all-visible
Date: Mon, 30 Mar 2026 19:50:11 +0000
Message-ID: <E1w7Ick-002CCc-1G@gemulon.postgresql.org> (raw)

Allow on-access pruning to set pages all-visible

Many queries do not modify the underlying relation. For such queries, if
on-access pruning occurs during the scan, we can check whether the page
has become all-visible and update the visibility map accordingly.
Previously, only vacuum and COPY FREEZE marked pages as all-visible or
all-frozen.

This commit implements on-access VM setting for sequential scans, tid
range scans, sample scans, bitmap heap scans, and the underlying heap
relation in index scans.

Setting the visibility map on-access can avoid write amplification
caused by vacuum later needing to set the page all-visible, which could
trigger a write and potentially an FPI. It also allows more frequent
index-only scans, since they require pages to be marked all-visible in
the VM.

Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/flat/CAAKRu_ZMw6Npd_qm2KM%2BFwQ3cMOMx1Dh3VMhp8-V7SOLxdK9-g%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b46e1e54d078def33b840ae1fa6c5236a7b12ec2

Modified Files
--------------
src/backend/access/heap/heapam.c         |  3 +-
src/backend/access/heap/heapam_handler.c |  6 ++-
src/backend/access/heap/pruneheap.c      | 66 ++++++++++++++++++++++++--------
src/backend/access/heap/vacuumlazy.c     |  2 +-
src/include/access/heapam.h              |  3 +-
5 files changed, 59 insertions(+), 21 deletions(-)



Message-ID: <E1w7Ick-002CCc-1G@gemulon.postgresql.org>
Permalink:  ../E1w7Ick-002CCc-1G@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w7Ick-002CCc-1G@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: melanieplageman@gmail.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Allow on-access pruning to set pages all-visible
  In-Reply-To: <E1w7Ick-002CCc-1G@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox