pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sebastien Flaesch <sebastien.flaesch@4js.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
To: Kirk Wolak <wolakk@gmail.com>
Cc: Geoff Winkless <pgsqladmin@geoff.dj>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Using CTID system column as a "temporary" primary key
Date: Wed, 29 Mar 2023 19:04:53 +0000
Message-ID: <AM9P191MB12860CE4ED02EEB3030076D7B0899@AM9P191MB1286.EURP191.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <f85a1d70ee8f9df8ec7be46cec623f11b43e4fb4.camel@cybertec.at>
References: <DBAP191MB12891F47802C3674F77BF751B0889@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>
	<CAEzk6feEGHzS_TexvevFmWhsYt7MYhUUEUE54stO7SPNbL_Ypg@mail.gmail.com>
	<DBAP191MB1289536BFF22FD8BD5FFEC61B0889@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>
	<CACLU5mQ2XMd5c4tetUHacVE538c8nd1t2CWSfDvis2GCKg0L9A@mail.gmail.com>
	<be2240923b8017b0c03f980772cdd6ef0678200a.camel@cybertec.at>
	<DBAP191MB128988C5A20F0A8714111FA6B0899@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>
	<f85a1d70ee8f9df8ec7be46cec623f11b43e4fb4.camel@cybertec.at>

Ok... sounds not good all in all.
Appreciate your help!
Thanks!
________________________________
From: Laurenz Albe <laurenz.albe@cybertec.at>
Sent: Wednesday, March 29, 2023 5:53 PM
To: Sebastien Flaesch <sebastien.flaesch@4js.com>; Kirk Wolak <wolakk@gmail.com>
Cc: Geoff Winkless <pgsqladmin@geoff.dj>; pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Using CTID system column as a "temporary" primary key

EXTERNAL: Do not click links or open attachments if you do not recognize the sender.

On Wed, 2023-03-29 at 14:23 +0000, Sebastien Flaesch wrote:
> From: Laurenz Albe <laurenz.albe@cybertec.at>
> > It is safe to assume that the CTID is stable within a single transaction
> > only if you use REPEATABLE READ or better transaction isolation level.
> >
> > With READ COMMITTED, you see updated rows (and consequently changed CTID)
> > within a single transaction.  And if you use SELECT ... FOR UPDATE, you
> > could even see a changed CTID within a single statement.
> >
> > So don't use CTID to identify rows unless you use REPEATABLE READ or better.
>
> Thanks for the advice about REPEATABLE READ isolation level!


... but that is only useful in a read-only scenario.

If you try to UPDATE the row in a REPEATABLE READ transaction, you
will get a serialization error if there was a concurrent update.

In short: don't use the CTID to identify a row.

Yours,
Laurenz Albe

view thread (28+ messages)  latest in thread

Message-ID: <AM9P191MB12860CE4ED02EEB3030076D7B0899@AM9P191MB1286.EURP191.PROD.OUTLOOK.COM>
Permalink:  ../AM9P191MB12860CE4ED02EEB3030076D7B0899@AM9P191MB1286.EURP191.PROD.OUTLOOK.COM/
Also on:    postgresql.org/message-id/AM9P191MB12860CE4ED02EEB3030076D7B0899@AM9P191MB1286.EURP191.PROD.OUTLOOK.COM

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: sebastien.flaesch@4js.com, laurenz.albe@cybertec.at, wolakk@gmail.com, pgsqladmin@geoff.dj
  Subject: Re: Using CTID system column as a "temporary" primary key
  In-Reply-To: <AM9P191MB12860CE4ED02EEB3030076D7B0899@AM9P191MB1286.EURP191.PROD.OUTLOOK.COM>
  References: <DBAP191MB12891F47802C3674F77BF751B0889@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM> <CAEzk6feEGHzS_TexvevFmWhsYt7MYhUUEUE54stO7SPNbL_Ypg@mail.gmail.com> <DBAP191MB1289536BFF22FD8BD5FFEC61B0889@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM> <CACLU5mQ2XMd5c4tetUHacVE538c8nd1t2CWSfDvis2GCKg0L9A@mail.gmail.com> <be2240923b8017b0c03f980772cdd6ef0678200a.camel@cybertec.at> <DBAP191MB128988C5A20F0A8714111FA6B0899@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM> <f85a1d70ee8f9df8ec7be46cec623f11b43e4fb4.camel@cybertec.at> <AM9P191MB12860CE4ED02EEB3030076D7B0899@AM9P191MB1286.EURP191.PROD.OUTLOOK.COM>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox