pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ilya Anfimov <ilan@tzirechnoy.com>
To: Matthias Apitz <guru@unixarea.de>
Cc: Karsten Hilbert <Karsten.Hilbert@gmx.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: lifetime of the old CTID
Date: Wed, 6 Jul 2022 18:56:02 +0300
Message-ID: <20220706155602.GA29353@azor.tzirechnoy.ru> (raw)
In-Reply-To: <20220706122600.GA24@sh4-5.1blu.de>
References: <03ca00a881de408016a907e31d832175b04aeac7.camel@cybertec.at>
	<20220705102201.GA9@sh4-5.1blu.de>
	<1c03b94b606f493bc6448b8559c4cccf806d3607.camel@cybertec.at>
	<YsReJL8fvHK0D8On@c720-r368166>
	<f363b79595205d42764ad7485aa46ab534f2d318.camel@cybertec.at>
	<YsUfHqpk4Ll1Dej3@c720-r368166>
	<9B418AE6-EA48-4493-B1D1-566708ADC9AC@thebuild.com>
	<YsUpQsTgf2rv1hk+@c720-r368166>
	<YsVZquEymElZ5TAK@hermes.hilbert.loc>
	<20220706122600.GA24@sh4-5.1blu.de>

On Wed, Jul 06, 2022 at 02:26:00PM +0200, Matthias Apitz wrote:
> El d??a Mittwoch, Juli 06, 2022 a las 11:45:14 +0200, Karsten Hilbert escribi??:
> 
> > Am Wed, Jul 06, 2022 at 08:18:42AM +0200 schrieb Matthias Apitz:
> > 

[skipped]

> WHERE-clause of its interest ("WHERE d01status=4"), here all books which
> are lent to patrons. This gives in the DB layer a CURSOR of say 100.000
> rows of the 3.000.000 in the table. Now the application fetches row
> by row and see if something should be done with the row. If so, the
> DB layer must LOCK the row for update. It does so using the CTID. Of
> course there is a key in the row (d01gsi, the signature of the book),
> but this is not uniqu and can't be used to lock exactly this row for update.

 Then add the primary key to the result of your function.
 The primary key for a table could easily be found in pg_constraint.

 You could even collapse it into one field and name it CTID in the resultset, if
it is strictly necessary by your logic.






view thread (25+ messages)  latest in thread

Message-ID: <20220706155602.GA29353@azor.tzirechnoy.ru>
Permalink:  ../20220706155602.GA29353@azor.tzirechnoy.ru/
Also on:    postgresql.org/message-id/20220706155602.GA29353@azor.tzirechnoy.ru

 · 

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: ilan@tzirechnoy.com, guru@unixarea.de, Karsten.Hilbert@gmx.net
  Subject: Re: lifetime of the old CTID
  In-Reply-To: <20220706155602.GA29353@azor.tzirechnoy.ru>
  References: <03ca00a881de408016a907e31d832175b04aeac7.camel@cybertec.at> <20220705102201.GA9@sh4-5.1blu.de> <1c03b94b606f493bc6448b8559c4cccf806d3607.camel@cybertec.at> <YsReJL8fvHK0D8On@c720-r368166> <f363b79595205d42764ad7485aa46ab534f2d318.camel@cybertec.at> <YsUfHqpk4Ll1Dej3@c720-r368166> <9B418AE6-EA48-4493-B1D1-566708ADC9AC@thebuild.com> <YsUpQsTgf2rv1hk+@c720-r368166> <YsVZquEymElZ5TAK@hermes.hilbert.loc> <20220706122600.GA24@sh4-5.1blu.de> <20220706155602.GA29353@azor.tzirechnoy.ru>

* 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