You are here: Re: JDBC deadlock on unrelated records « MsSQL Server « IT news, forums, messages
Re: JDBC deadlock on unrelated records

Posted by Simon Hayes on 09/06/05 17:20

Adding a primary key is certainly the best place to start, and would be
better than using query hints. Without a primary key, MSSQL has no way
to know that itemid is unique, so each process must always scan the
whole table, in case there are more rows with that itemid. Even if each
process is looking for a different itemid, they can't guarantee a
consistent update without locking the whole table, which seems to be
what is causing your problem - each process acquires more and more
locks until they run into a deadlock.

With the key, MSSQL will know that each process can lock only one row,
so if the itemid values are different there should be no problem. Even
if they are the same, process B will simply wait for the row or key
lock from process A to be freed, because it knows it doesn't need to
look for any more rows.

And of course adding a primary key is essential for data integrity, as
well as making your data model more explicit.

Simon

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация