简体   繁体   English

覆盖索引与聚集索引(数据库索引)

[英]Covering Index versus Clustered Index (Database Index)

I'm working on a database system and it's indexes, but I'm having a really hard time seing the clear difference between a covering index and a clustered index. 我正在使用数据库系统及其索引,但是要覆盖索引和聚簇索引之间的明显区别非常困难。

I've googled my way around but hasn't got a clear cut answer on: 我已经在Google上搜索了一下,但没有明确的答案:

  1. What is the differences between the two types of indexes 两种类型的索引有什么区别
  2. When do I use Covering index and when do I use Clustered index. 什么时候使用覆盖索引,什么时候使用聚簇索引。

I hope someone can explain it to me in a almost children-like answer :-) 我希望有人可以像孩子一样回答我:-)

Sincerely Mestika 真诚的梅斯蒂卡

By the way, I'm using IBM DB2 version 9.7 顺便说一句,我正在使用IBM DB2版本9.7

I cannot speak to DB2, but the following applies to SQL Server. 我无法与DB2交流,但是以下内容适用于SQL Server。

When all of the required columns are part of the index the index is called aa "covering index". 当所有必需的列都是索引的一部分时,该索引称为“覆盖索引”。 SQL Server 2005 introduced this type of index by allowing you to have "included columns" in the index. SQL Server 2005通过允许您在索引中包含“包含的列”而引入了这种类型的索引。 This allows you to include additional columns in the index over the 16 column limit or columns that would be too large to include. 这样,您就可以在索引中包括超出16列限制的其他列,或者这些列太大而无法包含。

While you can only have one clustered index per table, you can have up to 249 non-clustered indexes per table. 虽然每个表只能有一个聚集索引,但是每个表最多可以有249个非聚集索引。

By having a covering index available to satisfy a query, SQL Server won't need to go back to the clustered index to retrieve the rest of the data required by the query. 通过具有可用于满足查询的覆盖索引,SQL Server无需返回到聚簇索引即可检索查询所需的其余数据。

Randy 兰迪

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM