Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o97Ns-0007O0-9P for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 15:56:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o97Nr-00053e-41 for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 15:56:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o97Nq-00053V-Nb for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 15:56:10 +0000 Received: from carbon.misis.ru ([85.143.104.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o97Nn-0002ut-GN for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 15:56:09 +0000 Received: from mail.tzirechnoy.ru (unknown [10.1.250.11]) by carbon.misis.ru (Postfix) with ESMTP id 1183121229; Wed, 6 Jul 2022 18:56:02 +0300 (MSK) Received: by mail.tzirechnoy.ru (Postfix, from userid 1000) id D540DA42B1; Wed, 6 Jul 2022 18:56:02 +0300 (MSK) Date: Wed, 6 Jul 2022 18:56:02 +0300 From: Ilya Anfimov To: Matthias Apitz Cc: Karsten Hilbert , pgsql-general@lists.postgresql.org Subject: Re: lifetime of the old CTID Message-ID: <20220706155602.GA29353@azor.tzirechnoy.ru> Mail-Followup-To: Ilya Anfimov , Matthias Apitz , Karsten Hilbert , pgsql-general@lists.postgresql.org References: <03ca00a881de408016a907e31d832175b04aeac7.camel@cybertec.at> <20220705102201.GA9@sh4-5.1blu.de> <1c03b94b606f493bc6448b8559c4cccf806d3607.camel@cybertec.at> <9B418AE6-EA48-4493-B1D1-566708ADC9AC@thebuild.com> <20220706122600.GA24@sh4-5.1blu.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220706122600.GA24@sh4-5.1blu.de> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spamd-Result: default: False [-0.00 / 15.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FREEMAIL_ENVRCPT(0.00)[gmx.net]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_SOME(0.00)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[gmx.net,lists.postgresql.org]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-0.00)[10.75%] X-Rspamd-Queue-Id: 1183121229 X-Rspamd-Server: carbon List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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.