Re: existing row not found by SELECT ... WHERE CTID = ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ravi Krishna <srkrishna(at)vivaldi(dot)net>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Matthias Apitz <guru(at)unixarea(dot)de>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: existing row not found by SELECT ... WHERE CTID = ?
Date: 2022-05-25 14:38:24
Message-ID: 1924203.1653489504@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ravi Krishna <srkrishna(at)vivaldi(dot)net> writes:
>> No. PostgreSQL may remove a dead row, but a dead row is by definition
>> no longer visible, so it wouldn't be found by a query.

> I am wondering whether it is a good practice to use CTID in a where
> clause.

It's fine if part of your business logic is that you don't want to allow
concurrent updates. In this case, the OP seems to want to prevent rather
than tolerate the concurrent update, so I don't think he needs to revisit
the app's use of CTID.

If you do need to support concurrent updates, then yeah relying on CTID
is likely to be problematic.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2022-05-25 14:38:31 Re: connect permission based on database name
Previous Message Tom Lane 2022-05-25 14:35:17 Re: Connect to specific cluster on command line