On Fri, Sep 29, 2023 at 11:45 AM James Coleman <jtc...@gmail.com> wrote:my reading the issue is that "old versions" doesn't say > anything about "old HOT versions; it seems to be describing what > happens generally when a heap-only tuple is written -- which would > include the first time a heap-only tuple is written.
I think that it's talking about what happens during opportunistic pruning, in particular what happens to HOT chains. (Though pruning does almost the same amount of useful work with non-heap-only tuples, so it's a bit unfortunate that the name "HOT pruning" seems to have stuck.) > And when it's the > first heap-only tuple the "old version" would be the original version, > which would not be a heap-only tuple. The docs say "Old versions of updated rows can be completely removed during normal operation". Opportunistic pruning removes dead heap-only tuples completely, and makes their line pointers LP_UNUSED right away. But it can also entail removing storage for the original root item heap tuple, and making its line pointer LP_REDIRECT right away (not LP_DEAD or LP_UNUSED) at most once in the life of each HOT chain. So yeah, we're not quite limited to removing storage for heap-only tuples when pruning a HOT chain. Does that distinction really matter, though? There isn't even any special case handling for it in pruneheap.c (we only have assertions that make sure that we're performing "valid transitions" for each tuple/line pointer). That is, we don't really care about the difference between calling ItemIdSetRedirect() for an LP_NORMAL item versus an existing LP_REDIRECT item at the code level (we just do it and let PageRepairFragmentation() clean things up). -- Peter Geoghegan