p80152
80152
2017-04-19 15:17

ORACLE 索引查询SQL优化

1
  • oracle

有一样表test 建表语句如下所示,该表数据量10亿,有这一样条sql,

select * from test where (key1>? or(key1=? and key2>?) or (key1=? and key2=? and key3>?)) and (key1<? or(key1=? and key2<?) or (key1=? and key2=? and key3<?)) order by key1 asc,key2 asc,key3 asc;

这条sql 改怎么优化,test表的主键是b树索引。mysql 支持row comparisons 语法

支持这种形式(key1,key2,key3) > (?,?,?) and (key1,key2,key3)<=(?,?,?),那么oracle该怎么优化呢?求大牛指点

create table test
(
key1 int,
key2 int,
key3 int,
value int,
primary key(key1,key2,key3)
)

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答