为什么SQL Server将4字节整数添加到非唯一聚簇索引 [英] Why does SQL Server add a 4 byte integer to non-unique clustered indexes

查看:169
本文介绍了为什么SQL Server将4字节整数添加到非唯一聚簇索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以将非唯一列定义为聚簇索引以及非聚簇索引。但是,如果未将列定义为唯一,则SQL Server会在聚簇索引的情况下向索引列添加4字节整数。这样做是为了在内部保持记录的唯一性,即使两个或多个记录可能具有该列的值。为什么在非聚集索引的情况下不需要这个整数?

It is possible to define non-unique columns as clustered as well as non-clustered indexes. However, SQL Server adds a 4 byte integer to the indexed columns in case of a clustered index, if the column is not defined as unique. This is done to keep the "uniqueness" of the record internally even though two or more records may have the value for that column. Why isn't this integer necessary in case of a non-clustered index?

推荐答案

非聚集索引已包含聚簇索引列,以便它可以引用与之关联的确切行。因此,对于聚簇索引上的uniquifier,非聚集索引也将包括uniquifier。

A non-clustered index already includes the clustered index column so it can reference the exact row that it correlates to. Hence with the uniquifier on the clustered index, the non-clustered index would also include the uniquifier.

这里有一个很好的解释:理解和检查SQL Server中的Uniquifier

A good explanation here: Understanding and Examining the Uniquifier in SQL Server

这篇关于为什么SQL Server将4字节整数添加到非唯一聚簇索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆