From: Melanie Plageman <melanieplageman@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Set pd_prune_xid on insert
Date: Mon, 30 Mar 2026 20:08:50 +0000
Message-ID: <E1w7Iuo-002CIv-06@gemulon.postgresql.org> (raw)
Set pd_prune_xid on insert
Now that on-access pruning can update the visibility map (VM) during
read-only queries, set the page’s pd_prune_xid hint during INSERT and on
the new page during UPDATE.
This allows heap_page_prune_and_freeze() to set the VM the first time a
page is read after being filled with tuples. This may avoid I/O
amplification by setting the page all-visible when it is still in shared
buffers and allowing later vacuums to skip scanning the page. It also
enables index-only scans of newly inserted data much sooner.
As a side benefit, this addresses a long-standing note in heap_insert()
and heap_multi_insert(): aborted inserts can now be pruned on-access
rather than lingering until the next VACUUM.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
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/378a216187aea1b488ce60ed07dd1ac5c14a9984
Modified Files
--------------
src/backend/access/heap/heapam.c | 39 ++++++++++++++++++++++-------------
src/backend/access/heap/heapam_xlog.c | 19 ++++++++++++++++-
src/backend/access/heap/pruneheap.c | 18 +++++++---------
3 files changed, 51 insertions(+), 25 deletions(-)
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: Set pd_prune_xid on insert
In-Reply-To: <E1w7Iuo-002CIv-06@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