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红色那块的相关子查询很占资源,速度极其慢,怎么避免相关字查询,有什么方案可以代替?那段子查询的意思是 先要从主查询中取得 t.policy_id, t.product_id, t.endorse_id,然后取得policy_id相等,product_id相等的endorse最大的那一行
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红色那块的相关子查询很占资源,速度极其慢,怎么避免相关字查询,有什么方案可以代替?那段子查询的意思是 先要从主查询中取得 t.policy_id, t.product_id, t.endorse_id,然后取得policy_id相等,product_id相等的endorse最大的那一行
解决方案 »
- 字符集问题,帮忙看一下!
- oracle job,每年的第一天1点执行怎么写
- about EXECUTE IMMEDIATE question
- 修改了oracle的SPFILESID.ORA文件后无法登陆数据库,如何恢复~高手低手都速度啊
- 在进行Oracle 9i安装时,点击Setup,出现第一个画面后,就没反应了,请问是怎么回事。急
- ado连接oracle问题,急问!!!!
- 各位师哥帮我看一下怎么样才能提高效率!
- ORACLE的问题。。
- 请问:怎样知道Oracal8最近处理的SQL
- 不能做删除,表被锁住了吗?请问应该如何解决?
- 在plsql的匿名块中,能否嵌入一个函数或存储过程
- 求高手解析下面的语句
t_ri_endorse 这个表没有看到和其他表关联,会导致笛卡尔集。
而且如果不需要取出t_ri_endorse表中的字段的话,建议用exists
from t_ri_contract_log t0
1、t_ri_contract_log 的policy_id 和product_id是否有索引;
2、t_ri_endorse的endorse_id是否有索引,如果没有,就要看endorse_date是否有索引。检查完后,如果表数据量大,却没有索引,慢是理所当然的。最后建议楼主拿具体的数据,进行确认速度慢是否真的是子查询引起的。
希望对你有用
所以,你的sql本身是否存在问题呢?