sql - What determines the locking order for a multi-table query? -


does sql standard specify locking order multi-table query?

for example, given:

select department.id permissions, terminals, departments department.id = ? , terminal.id = ? , permissions.parent = department.id , permissions.child = terminals.id;

  1. does sql standard guarantee locking order or determined (implementation-specific) execution plan?
  2. is there way guarantee locking order?
  3. if there no way guarantee locking order, how supposed prevent deadlocks?

update: please not vote close issue without explaining reasoning. far i'm concerned, programming question, makes on-topic stackoverflow. if believe question needs further refined, please explain , more happy answer you.

according https://stackoverflow.com/a/112256/14731 lock order determined implementation-specific execution order. answer further goes on there isn't deterministic way prevent deadlocks. whereas in imperative programming can prevent deadlocks acquiring locks in same order, seems in declarative systems have work around them retrying operation when deadlock detected.

furthermore, argue since database execution plans change on lifetime technically impossible prevent deadlocks.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -