Groups | Blog | Home
all groups > sql server (alternate) > july 2004 >

sql server (alternate) : update deadlock question


jcharth NO[at]SPAM hotmail.com
7/29/2004 1:51:11 PM
hi can anyone tell me if the order of the update staments on multiple
tables can have an effect on deadlocks on a transactions.
for examples if i have a

dog -> dogid colorid breedid name
color-> colorid color
breed-> breedid breed


would it make any difference if i update the breed table before
updating the dog table?
Erland Sommarskog
7/29/2004 9:47:23 PM
Joseph (jcharth@hotmail.com) writes:
[quoted text, click to view]

Yes, the order of the update statement has importance, as far that if
different processes updates tables in different order, the risks for
a deadlock increases.

I'm afraid that I don't understand your example, so I cannot comment
on it particularly.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
jcharth NO[at]SPAM hotmail.com
8/2/2004 10:04:49 AM
thank for your tips, i believe the answer to my question is that if
several tables are update by 2 transactions the tables should be
Erland Sommarskog
8/2/2004 9:17:45 PM
Joseph (jcharth@hotmail.com) writes:
[quoted text, click to view]

Yes, this is a common entry on lists "How to avoid deadlocks". To be
more precise, this lists even say "Access tables in the same order".
It is however a rule which is almost impossible to adhere to in a complex
system with many different flows of logic.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
AddThis Social Bookmark Button