自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

用Oracle中的Statspack診斷數(shù)據(jù)庫性能實例

數(shù)據(jù)庫 Oracle 數(shù)據(jù)庫運維
Oracle Statspack 從Oracle8.1.6開始被引入Oracle,并馬上成為DBA和Oracle專家用來診斷數(shù)據(jù)庫性能的強有力的工具。

通過Statspack我們可以很容易的確定Oracle數(shù)據(jù)庫的瓶頸所在,記錄數(shù)據(jù)庫性能狀態(tài),也可以使遠程技術支持人員迅速了解你的數(shù)據(jù)庫運行狀況。因此了解和使用Statspack對于DBA來說至關重要。

整理分析結果

可以通過各種工具建立圖表,使我們收集的數(shù)據(jù)更直觀,更有說服力。
以下是我給一個客戶做的分析報告的實例。

1.物理讀寫IO操作:

觀察物理IO訪問,可以看出數(shù)據(jù)庫日常訪問的峰值及繁忙程度。

腳本:此腳本按時間生成統(tǒng)計數(shù)據(jù)(注:以下示例以8i為基礎,SQL腳本中引用的statistic#在不同版本代表的意義可能不同,對于9i等版本,你應該修改相應參數(shù)值)

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)>0

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)>0
/

圖表:

分析:

從趨勢圖中我們可以看出,數(shù)據(jù)庫每日讀操作較為平穩(wěn),數(shù)據(jù)量大約在4000左右。在下午2點到5點期
間比較繁忙。峰值達到150000左右。

數(shù)據(jù)庫寫操作變化也比較平穩(wěn),數(shù)據(jù)改變量在80000左右,凌晨一點半到早晨8點半左右數(shù)據(jù)庫訪問極少。
這是一個以寫為主的數(shù)據(jù)庫,我們需要更多注意的是寫競爭。

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#=41

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#=41

圖表:

分析:

Buffer(bufferhitratio)命中率是考察Oracle數(shù)據(jù)庫性能的重要指標,它代表在內(nèi)存中找到需要數(shù)據(jù)的比
率,一般來說,如果該值小于90%,則可能說明數(shù)據(jù)庫存在大量代價昂貴的IO操作,數(shù)據(jù)庫需要調(diào)整。
我們數(shù)據(jù)庫的buffer命中率幾乎接近100%,最低值在95%左右,這個比率是比較優(yōu)化的。

安裝statspack

SQL>connect/assysdba

SQL>@?/rdbms/admin/spcreate

卸載

SQL>connect/assysdba
SQL>@?/rdbms/admin/spdrop
/*
收集信息前把timed_statistics=true;
altersystemsettimed_statistics=true;
*/

收集信息

SQL>connectperfstat/perfstat
SQL>executestatspack.snap;

自動收集

SQL>connectperfstat/perfstat
SQL>@?/rdbms/admin/spauto

刪掉自動收集的job.

SQL>select*fromuser_jobs;

SQL>execdbms_job.remove(JOB_ID)

/*
executestatspack.snap(i_snap_level=>10,i_modify_parameter=>'true');
Levels=5Additionaldata:SQLStatements
Levels=6Thislevelincludesallstatisticsgatheredinthelowerlevel(s).

Levels=7segmentslevelstatistics
Levels=10Additionalstatistics:Childlatches
i_modify_parameter=>'true'/'false'決定是否保存level的值,下一次執(zhí)行繼續(xù)使用
*/

產(chǎn)生報告

SQL>conectperfstat/perfstat
SQL>@?/rdbms/admin/spreport

【編輯推薦】

  1. 詳解Oracle幾種性能調(diào)優(yōu)方法
  2. Oracle應用開發(fā)中的幾個經(jīng)典問題
  3. Oracle數(shù)據(jù)空間的使用、監(jiān)控和維護
責任編輯:彭凡 來源: javaeye
相關推薦

2011-05-19 13:25:14

Oracle數(shù)據(jù)庫

2010-06-17 12:59:07

Oracle

2011-05-26 14:49:50

ORACLE數(shù)據(jù)庫

2011-03-29 10:47:49

ORACLE數(shù)據(jù)庫

2010-04-14 15:45:49

Oracle 數(shù)據(jù)庫

2010-04-06 11:30:09

Oracle 數(shù)據(jù)庫

2011-03-25 09:37:17

2011-08-16 18:55:10

Oracle數(shù)據(jù)庫構造過程

2011-05-26 15:27:08

Oracle數(shù)據(jù)庫

2010-04-02 16:03:20

Oracle數(shù)據(jù)庫

2011-08-11 16:55:34

Oracle數(shù)據(jù)庫AWR

2011-05-20 10:30:20

ORACLE數(shù)據(jù)庫性能優(yōu)化

2011-05-18 09:39:19

Oracle數(shù)據(jù)庫性能優(yōu)化

2010-04-23 09:32:39

Oracle數(shù)據(jù)庫實例

2010-05-10 15:50:39

Oracle數(shù)據(jù)庫性能

2010-11-15 16:13:24

Oracle數(shù)據(jù)庫性能

2010-05-07 17:39:02

Oracle數(shù)據(jù)庫性能

2023-11-16 17:12:33

數(shù)據(jù)庫oracle

2011-08-24 15:36:30

2024-12-30 10:03:11

點贊
收藏

51CTO技術棧公眾號