oracle join速度慢,子查询参与join,性能很慢,如何解决?

select a.svoucherno,a.setid,a.year,a.totalmoney,a.voudate,

a.eid,e.name ename,mid,m.name mname,a.bid,b.name bname,

a.iid,a.pid,p.name pname

from (select v.svoucherno,v.setid,v.year,v.totaldeb totalmoney,

v.year||'-'||substr('00'||v.month,length('00'||v.month)-1,2)||'-'||substr('00'||v.day,length('00'||v.day)-1,2) voudate,

(select substr(aid,4,length(aid)-2) from assistantvoudetail avd

where instr(aid,'003')=1

and v.svoucherno=avd.svoucherno and line=1) eid,

(select substr(aid,4,length(aid)-2) from assistantvoudetail avd

where instr(aid,'004')=1

and v.svoucherno=avd.svoucherno and line=1) mid,

(select substr(aid,4,length(aid)-2) from assistantvoudetail avd

where instr(aid,'005')=1

and v.svoucherno=avd.svoucherno and line=1) bid,

(select substr(aid,4,length(aid)-2) from assistantvoudetail avd

where instr(aid,'006')=1

and v.svoucherno=avd.svoucherno and line=1) iid,

(select substr(aid,4,length(aid)-2) from assistantvoudetail avd

where instr(aid,'007')=1

and v.svoucherno=avd.svoucherno and line=1) pid,

(select substr(aid,4,length(aid)-2) from assistantvoudetail avd

where instr(aid,'008')=1

and v.svoucherno=avd.svoucherno and line=1) did

from voucher v) a,enterprise e,budget_type_prop m,budgetsection b,payoffkind p

where a.eid = e.eid and a.year=e.year

and a.mid = substr(m.code,2,3)

and a.bid = b.bid and a.year=b.year

and a.pid = p.pid and a.year=p.year

红字部分是子查询,单独执行比较快。

但结果和其他表连接,由于子查询没法建索引,导致比较慢,如何解决呢?

能想出的办法是先建子查询的结果插入新建表A,建好索引,再将A表和其他表连接,结果很快。

还有其他办法吗?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值