各位大虾:
谁能帮小弟优化一下这个sql啊,sf02表的数据在七千万左右,sf01表的数据在三千万左右,感激不尽:
select a.tcol2, a.departcode, a.sendtime, sum(a.mainamount) mainamount
from sf02 a
where a.ksdm = '11019204'
and exists
(select policyno
from sf01 b
where b.businessnature = '531'
union all select policyno from sf01 b where b.businessnature = '532'
and a.policyno = b.policyno)
and (a.kindcode = 'R21' or a.kindcode = 'R29')
and a.insert_time <= to_date('2011-09-05', 'yyyy-MM-dd')
and a.insert_time >= to_date('2000-08-25', 'yyyy-MM-dd')
group by a.tcol2, a.departcode, a.sendtime
谁能帮小弟优化一下这个sql啊,sf02表的数据在七千万左右,sf01表的数据在三千万左右,感激不尽:
select a.tcol2, a.departcode, a.sendtime, sum(a.mainamount) mainamount
from sf02 a
where a.ksdm = '11019204'
and exists
(select policyno
from sf01 b
where b.businessnature = '531'
union all select policyno from sf01 b where b.businessnature = '532'
and a.policyno = b.policyno)
and (a.kindcode = 'R21' or a.kindcode = 'R29')
and a.insert_time <= to_date('2011-09-05', 'yyyy-MM-dd')
and a.insert_time >= to_date('2000-08-25', 'yyyy-MM-dd')
group by a.tcol2, a.departcode, a.sendtime
解决方案 »
- WEB系统获取客户机MAC地址
- 马上去实习,请问工作中SSH重点是哪部分?我好去复习下。
- Struts2 出现异常
- 如何java实现对MIS系统监控?
- 求助osworkflow mysql持久化
- 如何在Java WEB系统中嵌入excel
- 搞J2ee的工资有多少??
- 【请教】springboot 2.0.0版本中如何通过http请求来停止应用
- idea java项目 启动时控制台显示Too much output to process啥原因?求指教
- openmeetings4.0.4在eclipse neon运行中出现的问题
- ssh action请求后 页面分割思路的问题
- 如何变成验证:数值常量的默认类型是int
2、sf01 表businessnature加索引没啊?晕,啥都看不出来,你提供的东西太少了。
sf01表businessnature的已经有索引,sf02表的几个字段也存在索引
至于分区,由于数据库是分公司的,我们好像是没有权限,如果但看这个SQL的话,是否还有优化的空间?