假如建立索引
Create index sy1 on t1(col1,col2)
则下面哪些会使用这个索引呢?
where col3='xxx'andcol1='xxx'
where col3='xxx'andcol1='xxx'andcol2='xxx'
where col1='xxx'andcol3='xxx'andcol2='xxx'
where col1='xxx'andcol2='xxx'andcol3='xxx'
where col3='xxx'andcol1='xxx'andcol4='xxx'andcol2='xxx'
where col3='xxx'andcol2='xxx'and col4='xxx'andcol1='xxx'
最初由 ysfc_ren 发布
[B]假如建立索引
Create index sy1 on t1(col1,col2)
则下面哪些会使用这个索引呢?
where col3='xxx'andcol1='xxx'
where col3='xxx'andcol1='xxx'andcol2='xxx'
where col1='xxx'andcol3='xxx'andcol2='xxx'
where col1='xxx'andcol2='xxx'andcol3='xxx'
where col3='xxx'andcol1='xxx'andcol4='xxx'andcol2='xxx'
where col3='xxx'andcol2='xxx'and col4='xxx'andcol1='xxx' [/B]
因素比较多,和你表里的数据量也有关系,可以自己详细看一下执行计划,做个测试.
最初由 ysfc_ren 发布
[B]假如建立索引
Create index sy1 on t1(col1,col2)
则下面哪些会使用这个索引呢?
where col3='xxx'andcol1='xxx'
where col3='xxx'andcol1='xxx'andcol2='xxx'
where col1='xxx'andcol3='xxx'andcol2='xxx'
where col1='xxx'andcol2='xxx'andcol3='xxx'
where col3='xxx'andcol1='xxx'andcol4='xxx'andcol2='xxx'
where col3='xxx'andcol2='xxx'and col4='xxx'andcol1='xxx' [/B]
如果基于规则的优化模式,都会用到索引.基于代价的就不一定了.