聚集和非聚集索引是什么意思? [英] What do Clustered and Non clustered index actually mean?

查看:119
本文介绍了聚集和非聚集索引是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有限的曝光DB,只使用DB作为应用程序员。我想知道集群和非聚集索引。
我googled,我发现是:


聚集索引是一种特殊类型的索引,
表中的记录是物理存储的
。因此表只能有
一个聚集索引。聚集索引的叶节点
包含数据
页。非聚集索引是一种
特殊类型的索引,其中索引的
逻辑顺序不是
与磁盘上的行的
的物理存储顺序匹配。
非聚簇索引的叶节点不包括
数据页。 http://stackoverflow.com/questions/91688/what-are-the-differencespros-cons-between-clustered-and-non-clustered-indexes\">聚簇索引和非聚簇索引之间的区别是什么?

解决方案



使用聚簇索引,行以与索引相同的顺序物理存储在磁盘上。因此,只能有一个聚集索引。



对于非聚集索引,有一个第二个列表,它有指向物理行的指针。您可以有许多非聚簇索引,但每个新索引将增加写入新记录所需的时间。



如果要返回所有列,通常从聚簇索引读取速度更快。您不必先到索引,然后再到表。



使用聚簇索引写入表可能会更慢,如果需要重新排列数据。


I have a limited exposure to DB and have only used DB as an application programmer. I want to know about Clustered and Non clustered indexes. I googled and what I found was :

A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages. A nonclustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a nonclustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.

What I found in SO was What are the differences between a clustered and a non-clustered index?.

Can someone explain this in plain English?

解决方案

With a clustered index the rows are stored physically on the disk in the same order as the index. Therefore, there can be only one clustered index.

With a non clustered index there is a second list that has pointers to the physical rows. You can have many non clustered indexes, although each new index will increase the time it takes to write new records.

It is generally faster to read from a clustered index if you want to get back all the columns. You do not have to go first to the index and then to the table.

Writing to a table with a clustered index can be slower, if there is a need to rearrange the data.

这篇关于聚集和非聚集索引是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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