关于 索引 的讨论??

[复制链接]
查看11 | 回复3 | 2009-1-4 14:52:28 | 显示全部楼层 |阅读模式
假如建立索引
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'
回复

使用道具 举报

千问 | 2009-1-4 14:52:28 | 显示全部楼层
最初由 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]

因素比较多,和你表里的数据量也有关系,可以自己详细看一下执行计划,做个测试.
回复

使用道具 举报

千问 | 2009-1-4 14:52:28 | 显示全部楼层
最初由 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]

如果基于规则的优化模式,都会用到索引.基于代价的就不一定了.
回复

使用道具 举报

千问 | 2009-1-4 14:52:28 | 显示全部楼层
测试一下不就知道了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行