Deadlocks in SQL Server 2008 R2
Server: SQL Server 2008R2 Clients: Excel/ADO - 8 clients Server hardware: 8 core/16GB Memory/OS:WinServer 2008SR2
Deadlocks happening on both Insert/Update and Merge/Matched stored procedures.
I have read much on here about insert/updating, and as a result, I have changed my Insert/Updates to Merge/Matched, but I am still getting VERY frequent Deadlock errors (about once every 10 minutes) from just 8 clients running in batch mode calling for updates at a rate of 2 per minute.
In contrast, each client inserts about 2开发者_C百科0,000 items per minute to another table with no issues at all.
I would love some assistance on solving these deadlock issues as I don't think such a measly 8 clients (especially Excel/ADO/VBA) should be able to stress out this DB!
Also note that I do not issue any SQL commands directly through the clients, all sql commands are called through stored procedures.
My current SP:
merge [dbo].[File_Level_Data] as TargetMerge
using(select @Name_of_File as name)as source
on (TargetMerge.Name_of_File = source.name)
when matched then
update
set
XXX1 = @XXX1,
ZZZ25 = @ZZZ25
when not matched then
insert
(XXX1,
ZZZ25
) values
(
@XXX1,
@ZZZ25
);
My deadlocks were being caused by a trigger that I had put in there years ago but didn't believe they were still there. Once I removed them, no more deadlocks.
精彩评论