日期:2014-05-17  浏览次数:21014 次

for 循环 速度极慢 就像死锁..
select t.endorse_id,
  t.contract_id,
  t.policy_id,
  t.product_id,
  t.validate_date,
  t.end_date,
  trt.treaty_type,
  t.treaty_id,
  (t.sar-t.risar)*t.exchange_rate as rtsar
  from t_ri_contract_log t,
  t_ri_contract_reinsurer trcr,
  t_ri_treaty trt,
  t_ri_endorse tre
  where tre.endorse_id = (select max(t1.endorse_id)
  from t_ri_contract_log t0,
  t_ri_endorse t1
  where t0.policy_id = t.policy_id
  and t0.product_id = t.product_id
  and t0.endorse_id < t.endorse_id
  and t1.endorse_id=t0.endorse_id
  and t1.endorse_date>=to_date(s_date, 'ddmmyyyy')
  and t1.endorse_date<=to_date(e_date, 'ddmmyyyy'))
   
  and t.contract_id = trcr.contract_id
  and trcr.reinsurer_code=reinsurer
  and t.treaty_id=trt.treaty_id
  and t.item_id in (select t0.item_id from t_ri_policy_product t0 where t0.master_id in(select t.item_id from t_ri_policy_product t ,t_product_life tt where t.master_id is null and t.product_id=tt.product_id and tt.benefit_type = 41)
  union select t.item_id from t_ri_policy_product t ,t_product_life tt where t.master_id is null and t.product_id=tt.product_id and tt.benefit_type = 41)


sql如上,我在sql窗口中查询不到一秒就出来了,但是我在debug的时候,就卡在for 那一行
游标就是上面那个sql
for cur in(上面的sql)loop

求助~~

------解决方案--------------------
贴点测试数据出来,没有数据,没法帮你测,光看代码,有点头晕!
------解决方案--------------------
借地儿顺便提一个问题,
执行的时候,与测试的时候,oracle的执行计划一样吗?