From: | Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "Eric Springer *EXTERN*" <ericwspringer(at)gmail(dot)com>, "pgeu-general(at)postgresql(dot)org" <pgeu-general(at)postgresql(dot)org> |
Subject: | Re: Order of locking in postgres SELECT FOR UPDATE |
Date: | 2015-03-16 09:33:32 |
Message-ID: | A737B7A37273E048B164557ADEF4A58B365A6F77@ntex2010i.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgeu-general |
Eric Springer wrote:
> I asked the question on Stack Overflow:
> http://stackoverflow.com/questions/29041327/order-of-locking-in-postgres-select-for-update
>
> but haven't got any answers, so reposting it here:
>
>
> Assuming both table a and b has a single row, the query:
>
> SELECT * FROM a, b FOR UPDATE
>
> should get two row-level locks (one on a, one on b). Is there any
> defined ordering in which the locks are acquired? And is there any way
> to require the lock from the table b to get acquired lock before the
> one from a (to avoid deadlocking with other transactions)?
This is *not* the list for questions like this,
but since your query locks the whole table anyway, you could
use two LOCK TABLE statements in the right order.
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas 'ads' Scherbaum | 2015-04-15 22:36:49 | German-speaking PostgreSQL Conference 2015 |
Previous Message | Oliver Elphick | 2015-03-15 06:30:54 | Re: Order of locking in postgres SELECT FOR UPDATE |