如例,建这样一个索引:
create index temp1 on(a,b,c,d)
那么在查询时,如果条件为:
where a = '' and c = ''
也能用到这个索引吗?为什么?
这是最左前缀之外的oracle特性吗?还是最左前缀的一种?
从网上搜的原理都太难理解,麻烦各位高手给通俗的讲解一下。
谢谢!
...全文
116410打赏收藏
ORACLE 中的单列索引和多列索引
如例,建这样一个索引: create index temp1 on(a,b,c,d) 那么在查询时,如果条件为: where a = '' and c = '' 也能用到这个索引吗?为什么? 这是最左前缀之外的oracle特性吗?还是最左前缀的一种? 从网上搜的原理都太难理解,麻烦各位高手给通俗的讲解一下。 谢谢!
能起作用,下面是例子:
在date,place,amount上的组合索引
select count(*) from record where date >'19991201' and date < '19991214' and amount >2000(< 1秒)
select date,sum(amount) from record group by date(11秒)
select count(*) from record where date >'19990901' and place in ('BJ','SH')(< 1秒)
分析:这是一个合理的组合索引。它将date作为前导列,使每个SQL都可以利用索引,并且在第一和第三个SQL中形成了索引覆盖,因而性能达到了最优。