生产环境,
sql文本:select a.perperscovlimit,
a.rate,
a.shortratecoefficient,
round(round(a.perperscovlimit * a.rate/1000, 2) * a.shortratecoefficient/100,2),
round(a.unitpremium * a.shortratecoefficient/100,2),
a.oricurpremium,
a.unitpremium,
a.*
from a,
b
where
a.actualid = b.firstid
and b.parentid in (select e.actualid
from e,
c
where c.topid = ‘3237196716494’
and c.actualid = e.actualid
and c.specid = 3653176) and a.planno = ‘01’ and a.coveragecode = ‘1055’
执行计划:
连接列都有索引,为什么不能是用b.parentid 去做关联,而是走了hash join ,尝试使用 NO_DECORRELATE() 去绑定,但是未生效,反而报错,报错信息:
NO_DECORRELATE() is inapplicable because there are no correlated columns.
你这是不相关子查询,如果子查询中有条件=a表或者b表中的列才是相关子查询,这个就是一个in,如果你想变成相关子查询,可以把红框内容改成and exists (select 1
from e,
c
where c.topid = ‘3237196716494’
and c.actualid = e.actualid
and c.specid = 3653176
and e.actualid=b.parentid) 这样试一下
selelct a.* from a
where a.planno = ‘01’ and a.coveragecode = ‘1055’
and a.actualid in (select b.firstid
from b,c,e where b.parentid =e.actualid and c.actualid = e.actualid and c.topid = ‘3237196716494’ and c.specid = 3653176)