Oracle性能优化(100分)

D

dlmn

Unregistered / Unconfirmed
GUEST, unregistred user!
某表jj_Grzzjh中有300多万条记录,我用如下Select 语句得到查询值:
select sum(jj_dwyj) into zzyjje from jj_grzjjh
where xt_grlb in (select xt_bh from xt_grlb where xt_lbbh=1) --xt_lbbh=1,表示在职人员
and dw_dnh in (select dw_dnh from dw_dwxx where substr(dw_cbzt,2,1)='1' or
substr(dw_cbzt,2,1)='3' and (xt_dwlxbh=21 or xt_dwlxbh=31 or xt_dwlxbh=41))
--21,31,41表示财政全供单位
and xt_ywbh=2 --业务编号为2,表示基本医疗
我按照where后 条件字段分别建立了索引字段,结果程序运行了3分钟左右才有结果,而像这样的语句在过程中有5处,运行这几句就需要将近20分钟时间,因而是不可以接受的

有好一点的优化办法吗?

 
in 的效率低,避免用在大的数据集里,

select sum(a.jj_dwyj) into zzyjje
from jj_grzjjh a , xt_grlb b ,dw_dwxx c
where a.xt_ywbh=2
and b.xt_lbbh=1
and (substr(c.dw_cbzt,2,1) in ('1' ,'3') and (c.xt_dwlxbh in (21, 31 ,41))
and a.xt_grlb = b.xt_bh
and a.dw_dnh = c.dw_dnh

表不是很清楚,不知道对不对^_^
 
接受答案了.
 

Similar threads

S
回复
0
查看
631
SUNSTONE的Delphi笔记
S
S
回复
0
查看
608
SUNSTONE的Delphi笔记
S
S
回复
0
查看
785
SUNSTONE的Delphi笔记
S
S
回复
0
查看
722
SUNSTONE的Delphi笔记
S
顶部