SQL Server 2005 中没有聚集索引的原因

我为 SQL SERVER 2005 数据库继承了一些数据库创建脚本.

I've inherited some database creation scripts for a SQL SERVER 2005 database.

我注意到的一件事是,所有主键都创建为 NON CLUSTERED 索引,而不是集群.

One thing I've noticed is that all primary keys are created as NON CLUSTERED indexes as opposed to clustered.

我知道每个表只能有一个聚集索引,并且您可能希望将它放在非主键列上以提高搜索查询性能等.但是没有其他 CLUSTERED 索引在有问题的桌子上.

I know that you can only have one clustered index per table and that you may want to have it on a non primary key column for query performance of searches etc. However there are no other CLUSTERED indexes on the tables in questions.

所以我的问题是,除了上述之外,是否有任何技术原因不在主键列上使用聚集索引.

推荐答案

在任何正常"数据或查找表上:不,我看不出任何原因.

On any "normal" data or lookup table: no, I don't see any reason whatsoever.

关于大容量导入表或临时表之类的东西 - 视情况而定.

On stuff like bulk import tables, or temporary tables - it depends.

对于某些人来说,令人惊讶的是,拥有一个好的聚集索引实际上可以加快 INSERT 或 UPDATE 等操作的速度.参见 Kimberly Tripps 优秀的聚集索引辩论继续...... 博文中她详细解释了为什么会这样.

To some people surprisingly, it appears that having a good clustered index actually can speed up operations like INSERT or UPDATE. See Kimberly Tripps excellent The Clustered Index Debate continues.... blog post in which she explains in great detail why this is the case.

从这个角度来看:我没有看到任何正当理由不拥有一个好的聚集索引(窄、稳定、独特、不断增加 = INT IDENTITY 作为最明显的选择)在任何 SQL Server 表上.

In this light: I don't see any valid reason not to have a good clustered index (narrow, stable, unique, ever-increasing = INT IDENTITY as the most obvious choice) on any SQL Server table.

要深入了解如何以及为什么选择集群键,请阅读 Kimberly Tripp 就该主题撰写的所有优秀博客文章:

To get some deep insights into how and why to choose clustering keys, read all of Kimberly Tripp's excellent blog posts on the topic:

http://www.sqlskills.com/BLOGS/KIMBERLY/category/Clustering-Key.aspx

http://www.sqlskills.com/BLOGS/KIMBERLY/category/Clustered-Index.aspx

来自索引女王"的好东西!:-)

Excellent stuff from the "Queen of Indexing" ! :-)

相关文章