非聚集索引中的行定位器 [英] Row Locator in Non Clustered Index

查看:294
本文介绍了非聚集索引中的行定位器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读有关Non Clustered Index的内容,该内容表示"Nonclustered索引仅包含索引列和行定位符中指向实际数据行的值,而不包含数据行本身.这意味着查询引擎必须采取其他步骤才能找到实际数据."

I was reading about Non Clustered Index which says that "Nonclustered index contain only the values from the indexed columns and row locators that point to the actual data rows, rather than contain the data rows themselves. This means that the query engine must take an additional step in order to locate the actual data."

查询-我对Row Locator不清楚.我假设它不是任何Primary key.后台发生了某些事情,与Row-Locator唯一标识行有关.

Query - I am not clear with Row Locator. I am assuming that it is not any Primary key. There is something happening in background which has to do with Row-Locator to uniquely identify the row.

推荐答案

如果表具有唯一的聚集索引,则行定位器"由聚集索引的列组成.

If the table has a unique clustered index, the "row locator" consists of the columns of the clustered index.

具有非唯一的聚集索引,行定位器"由聚集索引的列组成,再加上SQL Server添加的新字段以使引用唯一.新字段对用户不可见.它称为"uniqueifier",由四个字节组成.

With a non-unique clustered index, the "row locator" consists of the columns of the clustered index, plus a new field SQL Server adds to make the reference unique. The new field is invisible to users. It's called "uniqueifier" and consists of four bytes.

在没有聚集索引的表(即堆)中,行定位符"是RID或行标识符. RID指向物理位置.它由文件标识符(ID),页码和页面上的行号组成.

In a table without a clustered index (aka a heap), the "row locator" is a RID or row identifier. The RID points to a physical location. It consists of the file identifier (ID), page number, and number of the row on the page.

行定位器"的一个实际结果是,对于具有很多索引的表使用小的主键是有意义的:)

One practical consequence of the "row locator" is that it makes sense to have a small primary key for a table with a lot of indexes :) Full details on this MSDN page.

这篇关于非聚集索引中的行定位器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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