Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
631 views
in Technique[技术] by (71.8m points)

indexing - Why does SQL Server add a 4 byte integer to non-unique clustered indexes

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...