Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvO49-004tRw-Tj for pgsql-general@arkaria.postgresql.org; Tue, 24 Oct 2023 20:31:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qvO48-00D1Tb-5I for pgsql-general@arkaria.postgresql.org; Tue, 24 Oct 2023 20:31:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvO47-00D1TI-Qs for pgsql-general@lists.postgresql.org; Tue, 24 Oct 2023 20:31:51 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvO45-002813-54 for pgsql-general@lists.postgresql.org; Tue, 24 Oct 2023 20:31:50 +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 39OKVldX849350; Tue, 24 Oct 2023 16:31:47 -0400 From: Tom Lane To: Carlos Alves cc: pgsql-general@lists.postgresql.org Subject: =?UTF-8?Q?Re:_Question_about_tuple=C2=B4s_lock?= In-reply-to: <2fa29bee5e4a7c369f54f02198423814@tecnisys.com.br> References: <2fa29bee5e4a7c369f54f02198423814@tecnisys.com.br> Comments: In-reply-to Carlos Alves message dated "Tue, 24 Oct 2023 13:27:35 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <849348.1698179507.1@sss.pgh.pa.us> Date: Tue, 24 Oct 2023 16:31:47 -0400 Message-ID: <849349.1698179507@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Carlos Alves writes: > I need some help to understand why a transaction wiht a row delete > aquire a AccessExclusiveLock and a row update a ExclusiveLock. UPDATE can use the weaker lock type if it's not modifying any column that is part of a unique index. This is to allow concurrency with foreign-key checks that might wish to grab a read-only (shared) lock on such a tuple. A DELETE, or an UPDATE that is modifying key columns, has to conflict with foreign-key checks. regards, tom lane