关于oracle数据库索引

执行sql如下:
select *
from lm3.cc03
where aae017 in (
select distinct natl.jgid
from be3.agency_natl natl,
be3.agency_config conf
where natl.jgid = conf.jgid
and conf.ywlb = '02'
start with natl.jgid = '37100106'
connect by prior conf.jgid = conf.sjjgid

)
and aae036 >= to_date('20130101', 'yyyyMMdd')

lm3.cc03表中有aae017和aae036 的组合索引,也有aae036 的单独索引。
但是执行以上sql时,lm3.cc03检索用不上索引,为什么?
哪位大侠给指导一下,谢谢!

2个回答

不要用in,改为exists

select *
from lm3.cc03
where exists (
select distinct natl.jgid
from be3.agency_natl natl,
be3.agency_config conf
where natl.jgid = conf.jgid
and natl.jgid = aae017
and conf.ywlb = '02'
start with natl.jgid = '37100106'
connect by prior conf.jgid = conf.sjjgid

)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问