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分钟时间,因而是不可以接受的
有好一点的优化办法吗?
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分钟时间,因而是不可以接受的
有好一点的优化办法吗?