Following up on https://stackoverflow.com/a/16553083/14731...
I understand that it is important to maintain a consisting locking order for tables in order to reduce the frequency of deadlocks, and that this affects both UPDATE
and SELECT
statements [1]. But, does the same hold true for read-only rows?
If a row is populated once at initialization time and no one modifies it ever again, does it really matter what order we access it?
Given two transactions: T1, T2 and two read-only rows R1, R2
T1 reads R1, then R2 T2 reads R2, then R1
Can the transactions deadlock, even if I use SERIALIZABLE transaction isolation?
[1] If transaction isolation is REPEATABLE_READ
, T1 SELECT
s R1, R2 while T2 UPDATE
s R2, R1 a deadlock may occur.
CLARIFICATION: This question is not RDBMS-specific. I am under the impression that no implementation can deadlock on read-only rows. If you have a counter-example (for a concrete vendor), please post an answer demonstrating as much and I will accept it. Alternatively, post a list of all concrete implementations that you can prove will not deadlock (and the most complete list will get accepted).