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 1qvOFE-004uF0-L8 for pgsql-general@arkaria.postgresql.org; Tue, 24 Oct 2023 20:43:20 +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 1qvOFD-00DB6b-1p for pgsql-general@arkaria.postgresql.org; Tue, 24 Oct 2023 20:43:19 +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 1qvOFC-00DB6L-Mv for pgsql-general@lists.postgresql.org; Tue, 24 Oct 2023 20:43:18 +0000 Received: from delibird0001-4.locaweb.com.br ([201.76.49.101]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvOF9-00285f-Ai for pgsql-general@lists.postgresql.org; Tue, 24 Oct 2023 20:43:17 +0000 Received: from mcbain0007.email.locaweb.com.br (189.126.112.75) by delibird0001-1.locaweb.com.br id h70m5m2n8lgb for ; Tue, 24 Oct 2023 17:43:06 -0300 (envelope-from ) Received: from dragonite0053.email.locaweb.com.br (dragonite0053.email.locaweb.com.br [10.31.120.192]) by mcbain0007.email.locaweb.com.br (Postfix) with ESMTP id 436EB240585; Tue, 24 Oct 2023 17:39:39 -0300 (-03) x-locaweb-id: 8s5dompSY9lzdgYuzvdAqyhiRl4cod0b8PDapWOWPTg2esmM5m_eojrEGJxOJErhAjCtDXXvCF-pyed2Tk2BVExjr5fZPDmfC9ZC39P2lF848UmcLulYhdECrgQa9D6fLFHyyPOpcHyi3GAFhRmZY7hazhq9oiBg_B8KVi9MHKz37KK6QllAa1n7V2X_fddlJCAaWggifiTF2RwnxVhBA7mBcD3250_HwLGavGY2y4g= NjM2MTcyNmM2ZjczMmU2MTZjNzY2NTczNDA3NDY1NjM2ZTY5NzM3OTczMmU2MzZmNmQyZTYyNzI= x-locaweb-id: 8s5dompSY9lzdgYuzvdAqyhiRl4cod0b8PDapWOWPTg2esmM5m_eojrEGJxOJErhAjCtDXXvCF-pyed2Tk2BVExjr5fZPDmfC9ZC39P2lF848UmcLulYhdECrgQa9D6fLFHyyPOpcHyi3GAFhRmZY7hazhq9oiBg_B8KVi9MHKz37KK6QllAa1n7V2X_fddlJCAaWggifiTF2RwnxVhBA7mBcD3250_HwLGavGY2y4g= NjM2MTcyNmM2ZjczMmU2MTZjNzY2NTczNDA3NDY1NjM2ZTY5NzM3OTczMmU2MzZmNmQyZTYyNzI= Received: from webmail-seguro.com.br (localhost [127.0.0.1]) (Authenticated sender: carlos.alves@tecnisys.com.br) by dragonite0053.email.locaweb.com.br (Postfix) with ESMTPA id A086D2C0527; Tue, 24 Oct 2023 17:43:07 -0300 (-03) MIME-Version: 1.0 Date: Tue, 24 Oct 2023 17:43:07 -0300 From: Carlos Alves To: Tom Lane Cc: pgsql-general@lists.postgresql.org Subject: =?UTF-8?Q?Re=3A_Question_about_tuple=C2=B4s_lock?= In-Reply-To: <849349.1698179507@sss.pgh.pa.us> References: <2fa29bee5e4a7c369f54f02198423814@tecnisys.com.br> <849349.1698179507@sss.pgh.pa.us> Message-ID: X-Sender: carlos.alves@tecnisys.com.br User-Agent: Roundcube Webmail/1.4.11 Content-Type: multipart/alternative; boundary="=_9fe4decc0ba256d5c6e8651426d18d54" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_9fe4decc0ba256d5c6e8651426d18d54 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Em 24/10/2023 17:31, Tom Lane escreveu: > 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 Tom, thank you very much for your straight to the point answer! regards Carlos Alves --=_9fe4decc0ba256d5c6e8651426d18d54 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8

Em 24/10/2023 17:31, Tom Lane escreveu:

= Carlos Alves <carlos.alv= es@tecnisys.com.br> writes:
I need some help to understand why a transaction wiht = a row delete
aquire a AccessExclusiveLock and a row update a Exclusiv= eLock.

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 modi= fying key columns, has to
conflict with foreign-key checks.
            = ;regards, tom lane


Tom, 
=
thank you very much for your straight to the point answer!

regards
Carlos Alves


--=_9fe4decc0ba256d5c6e8651426d18d54--