Re: lifetime of the old CTID

From: Ilya Anfimov <ilan(at)tzirechnoy(dot)com>
To: Matthias Apitz <guru(at)unixarea(dot)de>
Cc: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: lifetime of the old CTID
Date: 2022-07-06 15:56:02
Message-ID: 20220706155602.GA29353@azor.tzirechnoy.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message DAVID ROTH 2022-07-06 16:06:52 Multiple Indexes
Previous Message Adrian Klaver 2022-07-06 15:42:56 Re: Seems to be impossible to set a NULL search_path