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

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

问题描述

我对 DB 的接触有限,并且仅将 DB 用作应用程序程序员.我想了解ClusteredNon clustered index.我用谷歌搜索,我发现的是:

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的叶子节点非聚集索引不包括数据页.取而代之的是叶节点包含索引行.

我在 SO 中发现的是 什么聚集索引和非聚集索引之间的区别是什么?.

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 indices, 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天全站免登陆