Re: SELECT FOR UPDATE - Mailing list pgsql-hackers

From Tom Lane
Subject Re: SELECT FOR UPDATE
Date
Msg-id 7869.1059138651@sss.pgh.pa.us
Whole thread Raw
In response to Re: SELECT FOR UPDATE  (Thomas Swan <tswan@idigx.com>)
Responses Re: SELECT FOR UPDATE  (Thomas Swan <tswan@idigx.com>)
List pgsql-hackers
Thomas Swan <tswan@idigx.com> writes:
> Hypothetically, if I knew the relations that contained the tuples I was 
> locking, I could conceivably visit them in, let's say, alphabetical 
> order or oid order or any predictable order, and then select the rows 
> for update (using oid order or primary key order).  It would be hard to 
> induce a deadlock condition if the locks being acquired where in a 
> consistently reproducible order by all processes. 

Given that this requires programmer discipline anyway, I think it's okay
to leave the whole thing in the hands of the programmer.  My original
comment that the locks are acquired in an unpredictable order wasn't
right --- they are acquired by the executor's top level, therefore
in the order the rows come out of the execution engine, and therefore
you can make the order predictable if you want to.  Just use ORDER BY.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: php with postgres
Next
From: "Shridhar Daithankar"
Date:
Subject: Re: [PERFORM] hardware performance and some more