Refactor heap_prune_chain() Keep track of the number of deleted tuples in PruneState and record this information when recording a tuple dead, unused or redirected. This removes a special case from the traversal and chain processing logic as well as setting a precedent of recording the impact of prune actions in the record functions themselves. This paradigm will be used in future commits which move tracking of additional statistics on pruning actions from lazy_scan_prune() to heap_prune_chain().
Simplify heap_prune_chain()'s chain traversal logic by handling each case explicitly. That is, do not attempt to share code when processing different types of chains. For each category of chain, process it specifically and procedurally: first handling the root, then any intervening tuples, and, finally, the end of the chain. While we are at it, add a few new comments to heap_prune_chain() clarifying some special cases involving RECENTLY_DEAD tuples. Author: Melanie Plageman <melanieplage...@gmail.com> Discussion: https://www.postgresql.org/message-id/20240330055710.kqg6ii2cdojsxgje@liskov Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/7aa00f1360e0c6938fdf32d3fbb8b847b6098b88 Modified Files -------------- src/backend/access/heap/pruneheap.c | 207 ++++++++++++++++++++---------------- 1 file changed, 116 insertions(+), 91 deletions(-)