- 论坛徽章:
- 0
|
数据库是9i的 ,应用做个报表,客户反映很慢
我跟踪了一个sql语句,发现很占cpu资源,
UPDATE tmptotal d
set d.produceday=(select sum(nvl(b.drQuantity,0))
from day_records b,Day_Record a,machine c
where a.recordid=b.recordid
and a.drdate>=c.begindate
and a.drstate = '2'
and b.machinecode = c.machinecode
and a.depcode = d.itemcode
and to_char(a.drDate,'YYYYMMDD') = to_char(:b3,'YYYYMMDD')
and c.MachineType<>'小水电机组'
and b.iftest='0'),
d.ratepower=(select nvl(sum(b.ratingpower*decode(a.depcode,'109',0.4,1)/10000),d.ratepower)
from day_records b,Day_Record a,machine c
where a.recordid=b.recordid
and a.drdate>=c.begindate
and a.drstate = '2'
and b.machinecode = c.machinecode
and a.depcode = d.itemcode
and to_char(a.drDate,'YYYYMMDD') = to_char(:b3,'YYYYMMDD')
and c.MachineType<>'小水电机组'
--and b.iftest='0'
)
where d.itemcode not in(:b2 || '_' || '1',:b2 || '_' || '2',:b2 || '_' || '3',:b2 || '_' || '4',:b2 || '_' || '5')
and d.iftest=0
and d.Random = :b1
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.01 0.00 0 0 0 0
Execute 1 25.70 25.73 0 176398 78 38
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 25.71 25.74 0 176398 78 38
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
之后我把优化器改成cbo
后来看了下这个语句的执行计划 也不高 cost在200左右
我看了下event 也都是一些关于control file 并行写之类的
请问这个是什么情况?有什么优化的思路么?? |
|