Set pd_prune_xid on insert
Melanie Plageman <melanieplageman@gmail.com>
Author:
Melanie Plageman <melanieplageman@gmail.com>
Date: 2026-03-30T20:07:11Z
Releases:
19 (unreleased)
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/heap/heapam.c | modified | +25 −14 |
| src/backend/access/heap/heapam_xlog.c | modified | +18 −1 |
| src/backend/access/heap/pruneheap.c | modified | +8 −10 |
Discussion
Cited messages not in the archive:
flat/CAAKRu_ZMw6Npd_qm2KM+FwQ3cMOMx1Dh3VMhp8-V7SOLxdK9-g@mail.gmail.com