Everybody knows that if one process goes
SELECT id FROM dead WHERE id = 'A' FOR UPDATE;
SELECT id FROM dead WHERE id = 'B' FOR UPDATE;
and another goes
SELECT id FROM dead WHERE id = 'B' FOR UPDATE;
SELECT id FROM dead WHERE id = 'A' FOR UPDATE;
then you risk deadlock. I would rather assume that
SELECT id FROM dead WHERE id IN ('A', 'B') FOR UPDATE;
will deadlock against
SELECT id FROM dead WHERE id IN ('B', 'A') FOR UPDATE;
but is the order of locking the IN list defined -- which of those will deadlock against my single-select process?
More precisely, if I have an alphabetic locking order convention then can I safely merge lock A and lock B into one SQL statement (given that slow networks might make reducing the number of network trips to the database a good thing).