SQL Server 2014?????????????????????
???????????? ???????[ 2015/7/7 13:54:56 ] ?????????????
????????????????????????????????????? Online Index Rebuild operations??????????SQL Server 2014????????????????????????????SQL Server 2005??????????????????????????????Щ????????????????????????????????????????SQL Server?????ù????????Shared Table Lock (S) ??????????????????????????ü?????????Schema Modification Lock (Sch-M) ?????????Щ????????????????????????????????marketing trick????????????“????”?????“????????”?????????
????????????SQL Server 2014?????????????????????????????????????????Щ????????????????????????????????????????ν???????????Lock Priority????????????????????????????????????
????1 ALTER INDEX idx_Col1 ON Foo REBUILD
????2 WITH
????3 (
????4 ONLINE = ON
????5 (
????6 WAIT_AT_LOW_PRIORITY
????7 (
????8 MAX_DURATION = 1??
????9 ABORT_AFTER_WAIT = SELF
????10 )
????11 )
????12 )
????13 GO
???????????????????????????WAIT_AT_LOW_PRIORITY??????????δ????????1??????MAX_DURATION????????????????——??????????????????ABORT_AFTER_WAIT???????????????????SQL Server?????SELF??ζ?????ALTER INDEX REBUILD???????????????BLOCKERS????????????????????????????????????????????????????????????С???????????????????????????????????????
???????????????????????????????????????????????????????????
1 -- Creates a new database
2 CREATE DATABASE Test
3 GO
4
5 -- Use the database
6 USE Test
7 GO
8
9 -- Create a simple table
10 CREATE TABLE Foo
11 (
12 Col1 INT IDENTITY(1?? 1) NOT NULL??
13 Col2 INT NOT NULL??
14 Col3 INT NOT NULL
15 )
16 GO
17
18 -- Create a unique Clustered Index on the table
19 CREATE UNIQUE CLUSTERED INDEX idx_Col1 ON Foo(Col1)
20 GO
21
22 -- Insert a few test records
23 INSERT INTO Foo VALUES (1?? 1)?? (2?? 2)?? (3?? 3)
24 GO
????????????????????????????????μ?????????????
????1 BEGIN TRANSACTION
????2
????3 UPDATE Foo SET Col2 = 2
????4 WHERE Col1 = 1
????????ζ?????????????????????????????Exclusive Lock (X)???????????????????????????Intent-Exclusive Lock (IX)????????????????????????Intent-Exclusive Lock (IX)????????????SQL Server????????????????Σ?locking hierarchy??????=>?=>????????????????????????IX Lock???????????????????????????????Shared Lock??????????——???????/???????η?????????????????????????????????????????????
????1 ALTER INDEX idx_Col1 ON Foo REBUILD
????2 WITH
????3 (
????4 ONLINE = ON
????5 )
????6 GO
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11