您的位置:首页 > 数据库 > Oracle

应用长短链接变更对于Oracle数据库性能的影响

2011-02-20 22:43 302 查看
Question:某客户的应用做过变更(短链变长链),现cpu利用率较之前有明显改善,参见附件中的awr报告。想咨询一下sql语句的执行时间,cpu Time等指标,是否会受到短链变长链影响,因为从awr报告看,性能有明显改善。

Load Profile
变更前:
Per SecondPer Transaction
Redo size:244,606.5913,269.94
Logical reads:5,964.59323.58
Block changes:1,278.4169.35
Physical reads:339.0318.39
Physical writes:35.301.92
User calls:693.4437.62
Parses:241.4613.10
Hard parses:0.160.01
Sorts:97.935.31
Logons:16.050.87
Executes:617.5533.50
Transactions:18.43
变更后:
Per SecondPer Transaction
Redo size:314,037.684,249.08
Logical reads:7,939.19107.42
Block changes:1,629.3522.05
Physical reads:221.232.99
Physical writes:41.850.57
User calls:1,005.1713.60
Parses:76.151.03
Hard parses:0.160.00
Sorts:37.360.51
Logons:0.360.00
Executes:810.1610.96
Transactions:73.91
Top 5 Timed Events
变更前:
EventWaitsTime(s)Avg Wait(ms)% Total Call TimeWait Class
CPU time2,43068.6
db file sequential read84,286416511.7User I/O
log file sync63,77326647.5Commit
db file scattered read74,97223536.6User I/O
enq: TX - row lock contention4632294946.5Application
变更后:
EventWaitsTime(s)Avg Wait(ms)% Total Call TimeWait Class
CPU time1,66174.0
log file sync167,658473321.1Commit
db file sequential read91,101411518.3User I/O
wait for scn ack145,79614216.3Other
log file parallel write166,14312115.4System I/O

Time Model Statistics

变更前:
Statistic NameTime (s)% of DB Time
sql execute elapsed time2,603.7373.47
DB CPU2,430.3768.58
connection management call elapsed time511.9014.45
parse time elapsed163.604.62
PL/SQL execution elapsed time84.882.40
hard parse elapsed time27.080.76
sequence load elapsed time17.880.50
hard parse (sharing criteria) elapsed time0.010.00
repeated bind elapsed time0.000.00
DB time3,543.74
background elapsed time513.68
background cpu time351.72
变更后:
Statistic NameTime (s)% of DB Time
DB CPU1,661.4274.02
sql execute elapsed time1,558.6469.44
PL/SQL execution elapsed time66.662.97
parse time elapsed37.241.66
hard parse elapsed time15.090.67
connection management call elapsed time8.370.37
sequence load elapsed time3.530.16
PL/SQL compilation elapsed time0.490.02
hard parse (sharing criteria) elapsed time0.080.00
failed parse elapsed time0.080.00
repeated bind elapsed time0.000.00
DB time2,244.66
background elapsed time669.28
background cpu time382.82

性能分析:

从这2个awr报告对比来看修改为长连接后单位小时的CPU TIME与DB TIME均有所下降,CPU TIME从原来的2430s下降到1661s,降幅为769s。但分析2个报告中的每秒逻辑读可以发现修改为长连接后的逻辑读反而增加了。CPU TIME主要可以分为parse cpu,execute cpu和fetch cpu。短连接时一小时的parse time即解析时间为163s;另外因为短连接时每秒登录数达到16个,Oracle为建立连接(connection management call)耗时511s。

总结以下几点:
1.短连接情况下因为新建立的会话没有缓存游标信息,进而导致无法避免大量的软解析,解析消耗了163s的DB TIME。修改为长连接后解析数量明显减少,解析仅消耗37s的DB TIME。
2.短连接情况下每秒登录数达到16次,建立连接(connection)同样会消耗大量的CPU TIME,这里connection management call消耗了约500s的CPU TIME。修改为长连接后每秒Logons数为0.36,节约了大量无谓的CPU浪费。
3.改为长连接后Top SQL的平均每次逻辑读并未下降,部分Top SQL的执行次数还有所增加;可见通过减少不必要的解析和反复建立连接,系统的性能得到了释放
4.原短连接的AWR报告中显示该时段内出现行锁等待(row lock contention)共463次,总耗时为229s,该等待事件也是造成2个报告中DB TIME差异的一个因素。而长连接报告中则没有该等待出现,这可能是出于偶然,也可能是程序修改导致的。本文出自 “Ask Maclean Liu Oracle” 博客,请务必保留此出处http://maclean.blog.51cto.com/2923249/1277705
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: