Re: [DOCS] HOT - correct claim about indexes not referencing old line pointers

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: James Coleman <jtc331(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [DOCS] HOT - correct claim about indexes not referencing old line pointers
Date: 2023-09-29 18:39:14
Message-ID: CAH2-Wz=9OSW+Fz=sMmqNouZ9O92ViY1wEsAWV6R3uJ+EKRvj_A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 29, 2023 at 11:04 AM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> > But when a HOT update happens the entry in an (logically unchanged)
> > index still points to the original heap tid, and that line item is
> > updated with a pointer to the new line pointer in the same page.
>
> It's true that the original root heap tuple (which is never a
> heap-only tuple) must have its line pointer changed from LP_NORMAL to
> LP_REDIRECT the first time pruning takes place that affects its HOT
> chain. But I don't think that referring to the root item as something
> along the lines of "an obsolescent/old tuple's line pointer" is
> particularly helpful.

To be clear, the existing wording seems correct to me. Even heap-only
tuples require line pointers. These line pointers are strictly
guaranteed to never be *directly* referenced from indexes (if they are
then we'll actually detect it and report data corruption on recent
versions). The name "heap-only tuple" quite literally means that the
tuple and its line pointer are only represented in the heap, and never
in indexes.

There is a related rule about what is allowed to happen to any
heap-only tuple's line pointer: it can only change from LP_NORMAL to
LP_UNUSED (never LP_DEAD or LP_REDIRECT). You can think of a heap-only
tuple as "skipping the LP_DEAD step" that regular heap tuples must go
through. We don't need LP_DEAD tombstones precisely because there
cannot possibly be any references to heap-only tuples in indexes -- so
we can't break index scans by going straight from LP_NORMAL to
LP_UNUSED for heap-only tuple line pointers.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message James Coleman 2023-09-29 18:45:35 Re: [DOCS] HOT - correct claim about indexes not referencing old line pointers
Previous Message James Coleman 2023-09-29 18:38:39 Re: Fix incorrect comment reference