如何在创建索引时对字段进行排序(SQL Server 2005 +)? [英] How to order fields on index creation (SQL Server 2005 +)?

查看:396
本文介绍了如何在创建索引时对字段进行排序(SQL Server 2005 +)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本文的图4所示,SQL Server 2005 +可以返回缺少索引的列表.它存储有关丢失索引的2条重要信息:

As this article's figure 4 says, SQL Server 2005 + can return you a list of missing indexes. It stores 2 important info about missing indexes:

[EqualityUsage],[InequalityUsage]

[EqualityUsage],[InequalityUsage]

如果我缺少索引,其中:

If I have a missing index where:

[EqualityUsage] ='col1',[InequalityUsage] ='col2'

[EqualityUsage]='col1',[InequalityUsage]='col2'

我应该用索引键列创建索引吗?

Should I create an index with Indexed Key Columns:

'col1,col2'

'col1,col2'

'col2,col1'

'col2,col1'

?

推荐答案

col1,col2

col1, col2

创建索引

转换由...返回的信息 sys.dm_db_missing_index_details成一个 CREATE INDEX语句,相等 列应放在 不平等列,以及它们 应该成为索引的关键. 包含的列应添加到 使用CREATE INDEX语句 INCLUDE子句.

To convert the information returned by sys.dm_db_missing_index_details into a CREATE INDEX statement, equality columns should be put before the inequality columns, and together they should make the key of the index. Included columns should be added to the CREATE INDEX statement using the INCLUDE clause.

这篇关于如何在创建索引时对字段进行排序(SQL Server 2005 +)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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