From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
---|---|
To: | Tender Wang <tndrwang(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: When creating index, why pointing to old version of tuple |
Date: | 2025-08-01 07:03:45 |
Message-ID: | CAEoWx2=XhC+MGqm9pyLng0er8M4+LtwHGydy7DcK3Fxzu2-jcg@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> 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.
Chao Li (Evan)
------------------------------
HighGo Software Inc.
https://www.highgo.com/
Tender Wang <tndrwang(at)gmail(dot)com> 于2025年8月1日周五 14:58写道:
>
>
> Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> 于2025年8月1日周五 14:47写道:
>
>> > If the index points to the newest version of the tuple, how do old
>> transactions read the old version of the tuple using an index scan for old
>> transactions?
>>
>> Say there is a long transaction x1, it is on-going.
>>
>> And transaction x2 started later than x1 started, and x2 created an
>> index. Should x1 be visible to the new index?
>>
>> My understanding is, the old transaction x1 cannot use the new index to
>> scan for the old version of the tuple. If you read my example, in the
>> index, the key is the new age value (99), while the old age value is 4,
>> thus using the old value will not hit the index entry.
>>
>
> Yeah, in your case, the index is non-visible for x1. Your saying is
> correct. But what if the table already has an index?
> --
> Thanks,
> Tender Wang
>
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2025-08-01 07:04:23 | Re: Trivial patch to fix a typo |
Previous Message | Tender Wang | 2025-08-01 06:58:22 | Re: When creating index, why pointing to old version of tuple |