Re: When creating index, why pointing to old version of tuple

2025-08-01 Thread Tom Lane
Chao Li writes: > I understand that, for updated tuples, old version's ctid points to new > version, that builds a chain of all versions. But my confusion is that, > when an index is created, older transactions and in-progress transactions > won't see the newly created index. I think this misunde

Re: When creating index, why pointing to old version of tuple

2025-08-01 Thread Chao Li
This explanation sounds reasonable to me. I didn't mean to "optimize" the logic, I was just trying to understand the behavior. Chao Li (Evan) -- HighGo Software Inc. https://www.highgo.com/ David G. Johnston 于2025年8月1日周五 15:50写道: > On Friday, August 1, 2025, Chao Li

Re: When creating index, why pointing to old version of tuple

2025-08-01 Thread Chao Li
> 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)

Re: When creating index, why pointing to old version of tuple

2025-07-31 Thread Tender Wang
Chao Li 于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 st

Re: When creating index, why pointing to old version of tuple

2025-07-31 Thread Chao Li
> 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

Re: When creating index, why pointing to old version of tuple

2025-07-31 Thread Tender Wang
Chao Li 于2025年8月1日周五 14:16写道: > Hi Community, > > Let me use a small example to demonstrate my observation. > > Step 1: create a simple table, insert a tuple and update it. > > create table ta (id int, name varchar(32), age int); > insert into ta values(1, 'aa', 4); > update ta set age=99 where i