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)?