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 1nts9f-000838-5g for pgsql-general@arkaria.postgresql.org; Wed, 25 May 2022 14:38:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nts9e-000890-1Q for pgsql-general@arkaria.postgresql.org; Wed, 25 May 2022 14:38:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nts9d-00087x-NR for pgsql-general@lists.postgresql.org; Wed, 25 May 2022 14:38:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nts9a-0004gt-Ql for pgsql-general@lists.postgresql.org; Wed, 25 May 2022 14:38:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 24PEcOfd1924204; Wed, 25 May 2022 10:38:24 -0400 From: Tom Lane To: Ravi Krishna cc: Laurenz Albe , Matthias Apitz , pgsql-general@lists.postgresql.org Subject: Re: existing row not found by SELECT ... WHERE CTID = ? In-reply-to: References: <1652228.1653408709@sss.pgh.pa.us> Comments: In-reply-to Ravi Krishna message dated "Wed, 25 May 2022 10:30:16 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1924202.1653489504.1@sss.pgh.pa.us> Date: Wed, 25 May 2022 10:38:24 -0400 Message-ID: <1924203.1653489504@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ravi Krishna 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