SQL Server: What is the difference between Index Rebuilding and Index Reorganizing?

前端 未结 7 1250
暗喜
暗喜 2021-02-05 05:37

What is the difference between Index Rebuilding and Index Reorganizing?

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-05 05:48

    In addition to the differences above (basically rebuild will create the index anew, and then "swap it in" for the existing one, rather than trying to fix the existing one), an important consideration is that a rebuild - even an Enterprise ONLINE rebuild - will interfere with snapshot isolation transactions.

    TX1 starts snapshot transaction
    TX1 reads from T

    TX2 rebuilds index on T
    TX2 rebuild complete

    TX1 read from T again:

    Error 3961, Snapshot isolation transaction failed in database because the object accessed by the statement has been modified by a DDL statement in another concurrent transaction since the start of this transaction. It is disallowed because the metadata is not versioned. A concurrent update to metadata can lead to inconsistency if mixed with snapshot isolation.

提交回复
热议问题