用Oracle中的Statspack诊断数据库性能实例-性能调优[Oracle防范]
本文“用Oracle中的Statspack诊断数据库性能实例-性能调优[Oracle防范]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
通过Statspack我们可以很简单的肯定Oracle数据库的瓶颈所在,记录数据库性能状况,也可以使远程技术支持人员疾速理解你的数据库运行情况.因此理解和利用Statspack关于DBA来说至关重要.
整理解析后果
可以通过各种工具成立图表,使我们汇集的数据更直观,更有说服力.
以下是我给一个客户做的解析报告的实例.
1.物理读写IO操作:
察看物理IO拜候,可以看出数据库平常拜候的峰值及繁忙程度.
脚本:此脚本按时间生成统计数据(注:以下示例以8i为底子,SQL脚本中引用的statistic#在差别版本代表的意义大概差别,关于9i等版本,你应当改正呼应参数值)
SQL代码
select
substr(to_char(snap_time,'yyyy-mm-ddHH24:MI:SS'),12),
(newreads.value-oldreads.value)reads,
(newwrites.value-oldwrites.value)writes
from
perfstat.stats$sysstatoldreads,
perfstat.stats$sysstatnewreads,
perfstat.stats$sysstatoldwrites,
perfstat.stats$sysstatnewwrites,
perfstat.stats$snapshotsn
where
newreads.snap_id=sn.snap_id
and
newwrites.snap_id=sn.snap_id
and
oldreads.snap_id=sn.snap_id-1
and
oldwrites.snap_id=sn.snap_id-1
and
oldreads.statistic#=40
and
newreads.statistic#=40
and
oldwrites.statistic#=41
and
newwrites.statistic#=41
and
(newreads.value-oldreads.value)>0
and
(newwrites.value-oldwrites.value)>0select
substr(to_char(snap_time,'yyyy-mm-ddHH24:MI:SS'),12),
(newreads.value-oldreads.value)reads,
(newwrites.value-oldwrites.value)writes
from
perfstat.stats$sysstatoldreads,
perfstat.stats$sysstatnewreads,
perfstat.stats$sysstatoldwrites,
perfstat.stats$sysstatnewwrites,
perfstat.stats$snapshotsn
where
newreads.snap_id=sn.snap_id
and
newwrites.snap_id=sn.snap_id
and
oldreads.snap_id=sn.snap_id-1
and
oldwrites.snap_id=sn.snap_id-1
and
oldreads.statistic#=40
and
newreads.statistic#=40
and
oldwrites.statistic#=41
and
newwrites.statistic#=41
and
(newreads.value-oldreads.value)>0
and
(newwrites.value-oldwrites.value)>0
/
图表:
解析:
从趋向图中我们可以看出,数据库每日读操作较为平稳,数据量大约在4000左右.在下午2点到5点期
间对比繁忙.峰值到达150000左右.
数据库写操作改变也对比平稳,数据改变量在80000左右,清晨一点半到早晨8点半左右数据库拜候极少.
这是一个以写为主的数据库,我们需求更多注意的是写竞争.
2.Buffer命中率
Sql代码
select
substr(to_char(snap_time,'yyyy-mm-ddHH24:MI'),12),
round(100*(((a.value-e.value)+(b.value-f.value))-(c.value-g.value))/
((a.value-e.value)+(b.value-f.value)))
"BUFFERHITRATIO"
from
perfstat.stats$sysstata,
perfstat.stats$sysstatb,
perfstat.stats$sysstatc,
perfstat.stats$sysstatd,
perfstat.stats$sysstate,
perfstat.stats$sysstatf,
perfstat.stats$sysstatg,
perfstat.stats$snapshotsn
where
a.snap_id=sn.snap_id
and
b.snap_id=sn.snap_id
and
c.snap_id=sn.snap_id
and
d.snap_id=sn.snap_id
and
e.snap_id=sn.snap_id-1
and
f.snap_id=sn.snap_id-1
and
g.snap_id=sn.snap_id-1
and
a.statistic#=39
and
e.statistic#=39
and
b.statistic#=38
and
f.statistic#=38
and
c.statistic#=40
and
g.statistic#=40
and
d.statistic#=41select
substr(to_char(snap_time,'yyyy-mm-ddHH24:MI'),12),
round(100*(((a.value-e.value)+(b.value-f.value))-(c.value-g.value))/
((a.value-e.value)+(b.value-f.value)))
"BUFFERHITRATIO"
from
perfstat.stats$sysstata,
perfstat.stats$sysstatb,
perfstat.stats$sysstatc,
perfstat.stats$sysstatd,
perfstat.stats$sysstate,
perfstat.stats$sysstatf,
perfstat.stats$sysstatg,
perfstat.stats$snapshotsn
where
a.snap_id=sn.snap_id
and
b.snap_id=sn.snap_id
and
c.snap_id=sn.snap_id
and
d.snap_id=sn.snap_id
and
e.snap_id=sn.snap_id-1
and
f.snap_id=sn.snap_id-1
and
g.snap_id=sn.snap_id-1
and
a.statistic#=39
and
e.statistic#=39
and
b.statistic#=38
and
f.statistic#=38
and
c.statistic#=40
and
g.statistic#=40
and
d.statistic#=41
图表:
解析:
Buffer(bufferhitratio)命中率是观察Oracle数据库性能的重要指标,它代表在内存中找到需求数据的比
率,普通来说,假如该值小于90%,则大概阐明数据库存在大量代价高贵的IO操作,数据库需求调整.
我们数据库的buffer命中率几近接近100%,最低值在95%左右,这个比率是对比优化的.
安装statspack
SQL>connect/assysdba |
卸载
SQL>connect/assysdba /* |
汇集信息
SQL>connectperfstat/perfstat |
自动汇集
SQL>connectperfstat/perfstat |
删掉自动汇集的job.
SQL>select*fromuser_jobs; |
产生报告
SQL>conectperfstat/perfstat |
以上是“用Oracle中的Statspack诊断数据库性能实例-性能调优[Oracle防范]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |