rmd*_*ssa 1 sql t-sql database sql-server indexing
我们有一张叫做table1
...... 的桌子
(c1 int indentity,c2 datetime not null,c3 varchar(50) not null,
c4 varchar(50) not null,c5 int not null,c6 int ,c7 int)
on column c1 is primary key(clusterd Index)
on column c2 is index_2(Nonclusterd)
on column c3 is index_2(Nonclusterd)
on column c4 is index_2(Nonclusterd)
on column c5 is index_2(Nonclusterd)
Run Code Online (Sandbox Code Playgroud)
它包含1000万条记录.我们有几个程序指向具有不同搜索条件的"table1":
select from table1 where c1=blah..and c2= blah.. and c3=blah..
select from table1 where c2=blah..and c3= blah.. and c4=blah..
select from table1 where c1=blah..and c3= blah.. and c5=blah..
select from table1 where c1=blah..
select from table1 where c2=blah..
select from table1 where c3=blah..
select from table1 where c4=blah..
select from table1 where c5=blah..
Run Code Online (Sandbox Code Playgroud)
除了上面创建非聚集索引或修改现有索引以获得良好的索引性能和减少执行时间的最佳方法是什么?
现在实际回应......
这里的技巧是您可以在任意数量的列上进行单列查找,以及复合列查找.您需要了解上面的查询执行的频率 - 对于那些很少运行的查询,您应该将它们从索引考虑因素中排除.
您可能最好在每个要查询的列上创建单个NCIX.如果返回的行数非常小,则可能就是这种情况,因为NCIX将能够处理"单一查找"查询以及复合查找.或者,除了覆盖复合索引之外,您还可以创建单列NCIX - 同样,决定因素是执行频率和返回的结果数.
归档时间: |
|
查看次数: |
554 次 |
最近记录: |