When creating index, why pointing to old version of tuple

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Tender Wang <tndrwang(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: When creating index, why pointing to old version of tuple
Date: 2025-08-01 07:50:47
Message-ID: CAKFQuwYEXNGxvrziL_gXM=xzt=C7wi4mUVbTb2pTw9AxcYE45Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Friday, August 1, 2025, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:

>
> > But what if the table already has an index?
>
> I have tested that, if I create the index first, then update the tuple,
> the index entry will only point to the new version of data. That's why my
> question was specifically about creating the index after updating the tuple.
>

IIUC it’s just a seemingly low-value optimization that no one has bothered
to implement. The code path in question handles both initial creation and
reindexing and the later needs to keep the chain intact for concurrent
readers. It just doesn’t seem worth it to offer 10% off new index
creations and then charging full price thereafter. It could actually be a
bit counter-productive since your initial evaluation period would be skewed
toward the positive.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2025-08-01 08:02:50 RE: Add support for specifying tables in pg_createsubscriber.
Previous Message Japin Li 2025-08-01 07:42:27 Re: [WIP]Vertical Clustered Index (columnar store extension) - take2