where 函数问题引起执行计划改变(复杂视图)

使用函数非常慢,使用变量很快
  FROM v_hldtotal_price a,
       v_balance_price b,
       v_hlddetail_price c,
       v_symbol_price d
WHERE a.t_date = b.t_date
   AND a.t_date = c.t_date
   AND a.t_date = d.t_date
   AND a.f_code = b.f_code
   AND a.f_code = c.f_code
   AND a.f_code = d.f_code
   AND a.f_code = :fcode
   AND a.t_date = fun_date_start_last_end (:YEAR, :num, :style, :fcode)

 

修改办法:釜底抽薪
explain plan for   SELECT nvl (a.a701, 0) AS a701, nvl (a.a604, 0) AS a604,
       nvl (c.a100201, 0) AS a100201, nvl (d.bb, 0) AS bb,
       nvl (d.bc, 0) AS bc, nvl (d.fbd, 0) AS fbd,
       (nvl (b.a601102, 0) + nvl (b.a610103, 0)) AS zchzq, nvl (d.e, 0) AS e,
       nvl (d.feq, 0) AS feq, 0 other_qyzc, nvl (c.a2202, 0) AS a2202

 

  FROM (select * from TYDW.V_HLDTOTAL_PRICE where T_date=TYDW.fun_date_start_last_end (:YEAR, :num, :style, :fcode))   a,
       (select * from TYDW.v_balance_price where T_date=TYDW.fun_date_start_last_end (:YEAR, :num, :style, :fcode))  b,
       (select * from TYDW.v_hlddetail_price where T_date=TYDW.fun_date_start_last_end (:YEAR, :num, :style, :fcode))   c,
       (select * from TYDW.v_symbol_price where T_date=TYDW.fun_date_start_last_end (:YEAR, :num, :style, :fcode)) d
 WHERE a.t_date = b.t_date
   AND a.t_date = c.t_date
   AND a.t_date = d.t_date
   AND a.f_code = b.f_code
   AND a.f_code = c.f_code
   AND a.f_code = d.f_code
   AND a.f_code = :fcode

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值