September 13, 2005 at 7:54 pm
Hi,
Could anybody help me with deadlock.I have captured the deadlock procs info in error log.I can see both spid's are on same Stored proc and same statement.The staement is something like this
insert into (select from.........)
I can see in the error log that lock is at index level(key) i.e row lock occurs with in an index(cluster index).How can I resolve index level locks to avoid simialr deadlock in feature?
Any help is appreciated.
Thanks,
Sree
Thanks,
SR
September 13, 2005 at 9:36 pm
If you just want to query the data in the table, try to add "NOLOCK" option in your query statement, because with this statement if someone lock that record the query will display the result.
For example : insert into TableA (Field1,FieldB) select FieldA,FieldB from TableB NOLOCK
September 15, 2005 at 12:32 am
Yes the Nolock will allow the select to proceed, therefore completing the Insert
Can it be that the select performance could be improved ?
DB
The systems fine with no users loggged in. Can we keep it that way ?br>
September 15, 2005 at 12:41 am
Yes, because the query statement doesn't need to wait until the user release the record from the locking process.
For example :
TableA has a 100 records, record number 40 has been lock by UserA and record number 70 has been lock by UserB. If we do the query without NOLOCK statement, the query will wait until userA and UserB releasing the record. But if we add the "NOLOCK" the query will run and give the query result.
September 15, 2005 at 4:15 am
Hmmmm... surely there's more to this?
1. For a deadlock there should be 4 statements - 2 to compete for locks, and 2 to have created the locks that the other 2 are fighting over?
2. Even if the NOLOCK hint seems to have the desired effect, that puts each statement using it at some integrity risk. Since they're INSERTs, is it really desirable to insert data based on a condition which may change during the INSERT?
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply