我的表中有四列(a、b、c、d),它们都依赖于列(日期),所以在我的查询中我有:
select a where date
select b where date
select c where date
select d where date
我需要知道为所有这些创建索引的最佳方法是什么,我有两个建议:
第一个建议:
create i_a on a
create i_b on b
create i_c on c
create i_d on d
create i_date on date
第二个建议:
create i_a on a include date
create i_b on b include date
create i_c on c include date
create i_d on d include date
请问哪个更好。
最佳答案
这可能对您有帮助:
CREATE NONCLUSTERED INDEX Index_Name ON TableName(Date) INCLUDE(A,B,C,D)
您想要索引的列应该是用于过滤的列(WHERE
子句)。您可以添加 INCLUDE
以避免查找。
关于sql - 在 SQL Server 中创建索引的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29643885/