]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Set pd_prune_xid on insert
authorMelanie Plageman <melanieplageman@gmail.com>
Mon, 30 Mar 2026 20:07:11 +0000 (16:07 -0400)
committerMelanie Plageman <melanieplageman@gmail.com>
Mon, 30 Mar 2026 20:07:11 +0000 (16:07 -0400)
commit378a216187aea1b488ce60ed07dd1ac5c14a9984
tree8c5306b831a24c57857a20e8b3a30de42ac10c5e
parentb46e1e54d078def33b840ae1fa6c5236a7b12ec2
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
src/backend/access/heap/heapam.c
src/backend/access/heap/heapam_xlog.c
src/backend/access/heap/pruneheap.c