Re: Quick question regarding HeapTupleHeaderData.t_ctid

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Quick question regarding HeapTupleHeaderData.t_ctid
Date: 2022-06-12 16:55:08
Message-ID: CAJ7c6TOOV6ASi-tUx1-hfrhXW_btCZTv8zYkBhLUTCqrJAxOaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tom,

> > Which brings a question, maybe it shouldn't
> > take that much space on disk.
>
> How would you make it optional? In particular, what are you going to
> to when it's time to update a row (and therefore insert a ctid link)
> and the page is already completely full?

In other words, if I have an ItemPointer to an old tuple and try to
UPDATE it, t_ctid allows me to find the next page with another HOT
chain and, if possible, add a new tuple to that HOT chain. And
although there are newer versions of the tuple they are not
necessarily alive, e.g. if the corresponding transactions were
aborted, or they are running and it's not clear whether they will
succeed or not. I didn't think about this scenario.

It also explains why t_ctid can't be variable in size depending on
whether it points to a tuple in the same page or in the different one.
Next time we change t_ctid its size may change which will require
resizing the tuple, and the whole story becomes very complicated.

I think I get it now. Many thanks!

Just to clarify, is t_ctid used for anything _but_ HOT?

--
Best regards,
Aleksander Alekseev

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2022-06-12 17:10:34 Re: Quick question regarding HeapTupleHeaderData.t_ctid
Previous Message Tom Lane 2022-06-12 15:24:37 Re: Quick question regarding HeapTupleHeaderData.t_ctid