How to order fields on index creation (SQL Server 2005 +)?

只谈情不闲聊 提交于 2019-12-24 21:20:02

问题


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]

If I have a missing index where:

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

Should I create an index with Indexed Key Columns:

'col1,col2'

or

'col2,col1'

?


回答1:


col1, col2

CREATE INDEX

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.




回答2:


if you had only one of the two to search with, which would it be? list that first



来源:https://stackoverflow.com/questions/797830/how-to-order-fields-on-index-creation-sql-server-2005

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!