背景:
开始并不在意索引视图会导致死锁。
问题:
出现死锁,update t1 表尽然发现会去锁t2表从而导致死锁。
原因:
是因为索引视图才会导致死锁问题。单从update的执行计划也能看出问题
例子:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
create
table
t1(id
int
primary
key
,a
int
)
create
table
t2(id
int
primary
key
,a
int
)
go
CREATE
VIEW
[dbo].[DLV_AllProductItems]
WITH
SCHEMABINDING
AS
SELECT
a.id,a.a,b.id
as
idb,b.a
as
ab
FROM
dbo.t1 a
inner
join
dbo.t2 b
on
a.id = b.id
GO
create
unique
clustered
index
ix
on
t(id)
update
t1
set
a=1
where
id =1
|
本文转自 Fanr_Zh 博客园博客,原文链接:http://www.cnblogs.com/Amaranthus/p/6238339.html,如需转载请自行联系原作者