Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

`question about key-range lock

$
0
0
create table foo (c1 int)
go
insert into foo values (1)
insert into foo values (5)
insert into foo values (9)
create   clustered index foo_ci on foo(c1)
set tran isolation level serializable
begin tran
select * from foo where c1 = 5

for the above query, we know it would generate two RangeS-S,one for key 5 and the other is for key 9. that is to say it would prevent inserting values like 6,7,8 as there's a RangeS-S for key 9.

so my question is why SQL server needs the RangeS-S for key 9?  doesn't it enough just a RangeS-S for key 5 preventing the Phantom?

In other words, what will happen or the side effect if we remove the RangeS-S for key 9?



Please click the Mark as Answer button if a post solves your problem!




Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>