Re: Question about tuple´s lock

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Carlos Alves <carlos(dot)alves(at)tecnisys(dot)com(dot)br>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Question about tuple´s lock
Date: 2023-10-24 20:31:47
Message-ID: 849349.1698179507@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Carlos Alves <carlos(dot)alves(at)tecnisys(dot)com(dot)br> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Carlos Alves 2023-10-24 20:43:07 Re: Question about tuple´s lock
Previous Message Ron 2023-10-24 19:59:29 Re: setting up streaming replication