上面错了,也许是这样 select * from 表 WITH(INDEX = XXX)where t3= and t9=
Mengmou的好像不对,因为T2没有当前导列出现
select * from 表 WITH(INDEX = indexname )where t2=t2 and t3= and t9=
mengmou select * from 表 WITH(INDEX = XXX)where t3= and t9= 和 select * from 表 where t2=t2 and t3= and t9= 的执行计划是一样的 mengmou 的好一点
-- 用到索引的,是index scanselect * from table where t3= and t9=-- 要求是没有要求用t2 -- 如果用t2 -- index seekselect * from table where t2= and t3= and t9=
select * from 表 where t3= and t9= 就行 如果加t2 就按t2= t3= t9=
我测试了下, select * from 表 where t2=t2 and t3= and t9= 和 select * from 表 where t3= and t9= 都用到了上面说的索引,分析的成本也相差无几,可有的书说 select * from 表 where t3= and t9= 不会用到上面说的索引,真是疑惑?!
ON table(t3,t9)
select * from 表 where t3= and t9=
要使用这索引 要 T2,T3,T9 一起使用
select * from 表 WITH(INDEX = XXX)where t3= and t9=
select * from 表 WITH(INDEX = XXX)where t3= and t9= 和 select * from 表 where t2=t2 and t3= and t9= 的执行计划是一样的 mengmou 的好一点
-- 如果用t2
-- index seekselect * from table where t2= and t3= and t9=
如果加t2
就按t2= t3= t9=
select * from 表 where t2=t2 and t3= and t9=
和
select * from 表 where t3= and t9=
都用到了上面说的索引,分析的成本也相差无几,可有的书说 select * from 表 where t3= and t9= 不会用到上面说的索引,真是疑惑?!