首页 > 应用开发 > IT综合 > 详细解读 STATSPACK 报告
说在前面,很容易被忽略的几个点:在读报告的时候,我们首先需要看清楚,留意3个内容,这份报告所对应的数据库版本,cluster方式,以及报告的时间段。尤其需要注意的就是时间段,脱离了时间段的statspck将是毫无意义的,甚至会得出错误的结果。
STATSPACK report for
/* 报表头信息,数据库实例相关信息,包括数据库名称、ID、版本号及主机明等信息。
另外,重点还需要关注一下报告产生的时间跨度(在这里是14分钟),以及并发数(在这里是272)。
DB Name DB Id Instance Inst Num Release Cluster Host
———— ———– ———— ——– ———– ——- ————
ORA92 1924035339 ora92 1 9.2.0.6.0 NO jsdxh_db02
Snap Id Snap Time Sessions Curs/Sess Comment
——— —————— ——– ——— ——————-
Begin Snap: 13 14-Jul-07 00:18:52 274 55,345.0
End Snap: 14 14-Jul-07 00:32:55 272 55,823.8
Elapsed: 14.05 (mins)
Cache Sizes (end)
~~~~~~~~~~~~~~~~~
Buffer Cache: 5,120M Std Block Size: 8K
Shared Pool Size: 400M Log Buffer: 2,048K
Load Profile
~~~~~~~~~~~~ Per Second Per Transaction
————— —————
Redo size: 422,086.46 4,706.23
Logical reads: 23,200.54 258.68
Block changes: 3,080.59 34.35
Physical reads: 31.46 0.35
Physical writes: 104.38 1.16
User calls: 409.32 4.56
Parses: 227.20 2.53
Hard parses: 7.22 0.08
Sorts: 213.87 2.38
Logons: 0.85 0.01
Executes: 1,191.32 13.28
Transactions: 89.69
/* 下面详细说明Load Profile各项含义
Redo size:每秒产生的日志大小(单位字节),可标志数据变更频率, 数据库任务的繁重与否。
Logical reads:平决每秒产生的逻辑读的block数。Logical Reads= Consistent Gets + DB Block Gets
Block changes:每秒block变化数量,数据库事物带来改变的块数量。
Physical reads:平均每秒数据库从磁盘读取的block数。
Physical writes:平均每秒数据库写磁盘的block数。
User calls:每秒用户调用次数。
Parses:每秒解析次数,包括fast parse,soft parse和hard parse三种数量的综合。软解析每秒超过300次意味着你的”应用程序”效率不高,调整session_cursor_cache。在这里,fast parse指的是直接在PGA中命中的情况(设置了session_cached_cursors=n);soft parse是指在shared pool中命中的情形;hard parse则是指都不命中的情况。
Hard parses:每秒产生的硬解析次数, 每秒超过100次,就可能说明你绑定使用的不好,也可能是共享池设置不合理。这时候可以启用参数cursor_sharing= similar|force,该参数默认值为exact。但该参数设置为similar时,存在bug,可能导致执行计划的不优。
Sorts:每秒产生的排序次数。
Logons:每秒登陆的次数。
Executes:每秒执行次数。
Transactions:每秒产生的事务数,反映数据库任务繁重与否。
% Blocks changed per Read: 13.28 Recursive Call %: 80.21
Rollback per transaction %: 0.03 Rows per Sort: 2.84
/* Load Profile 续
Instance Efficiency Percentages (Target 100%)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Buffer Nowait %: 99.98 Redo NoWait %: 100.00
Buffer Hit %: 99.87 In-memory Sort %: 100.00
Library Hit %: 99.67 Soft Parse %: 96.82
Execute to Parse %: 80.93 Latch Hit %: 96.10
Parse CPU to Parse Elapsd %: 6.93 % Non-Parse CPU: 99.88
/* 实例的有效性,这部分值越接近100越好,分项内容详细说明如下:
Shared Pool Statistics Begin End
—— ——
Memory Usage %: 32.87 33.12
% SQL with executions>1: 80.00 82.69
% Memory for SQL w/exec>1: 77.62 80.70
小结:通过ORACLE的实例有效性统计数据,我们可以获得大概的一个整体印象,然而我们并不能由此来确定数据运行的性能。当前性能问题的确定,我 们主要还是依靠下面的等待事件来确认。我们可以这样理解两部分的内容,hit统计帮助我们发现和预测一些系统将要产生的性能问题,由此我们可以做到未雨绸 缪。而wait事件,就是表明当前数据库已经出现了性能问题需要解决,所以是亡羊补牢的性质。
接下来,开始查看wait事件。
/* oracle等待事件是衡量oracle运行状况的重要依据及指示,等待事件分为两类:空闲等待事件和非空闲等待事件, TIMED_STATISTICS = TRUE 那么等待事件按等待的时间排序,= FALSE那么事件按等待的数量排序。运行statspack期间必须session上设置TIMED_STATISTICS = TRUE,否则统计的数据将失真。空闲等待事件是oracle正等待某种工作,在诊断和优化数据库时候,不用过多注意这部分事件,非空闲等待事件专门针对 oracle的活动,指数据库任务或应用程序运行过程中发生的等待,这些等待事件是我们在调整数据库应该关注的。
对于常见的等待事件,说明如下:
对于常见的一些IDLE wait事件举例:
dispatcher timer
lock element cleanup
Null event
parallel query dequeue wait
parallel query idle wait - Slaves
pipe get
PL/SQL lock timer
pmon timer- pmon
rdbms ipc message
slave wait
smon timer
SQL*Net break/reset to client
SQL*Net message from client
SQL*Net message to client
SQL*Net more data to client
virtual circuit status
client message
SQL*Net message from client
下面是关于这里的常见的等待事件和解决方法的一个快速预览
| 等待事件 | 一般解决方法 |
| Sequential Read | 调整相关的索引和选择合适的驱动行源 |
| Scattered Read | 表明出现很多全表扫描。优化code,cache小表到内存中。 |
| Free Buffer | 增大DB_CACHE_SIZE,增大checkpoint的频率,优化代码 |
| Buffer Busy Segment header | 增加freelist或者freelistgroups |
| Buffer Busy Data block | 隔离热块;使用反转索引;使用更小的块;增大表的initrans |
| Buffer Busy Undo header | 增加回滚段的数量或者大小 |
| Buffer Busy Undo block | Commit more;增加回滚段的数量或者大小 |
| Latch Free | 检查具体的等待latch类型,解决方法参考后面介绍 |
| Enqueue-ST | 使用本地管理的表空间或者增加预分配的盘区大小 |
| Enqueue-HW | 在HWM之上预先分配盘区 |
| Enqueue-TX4 | 在表或者索引上增大initrans的值或者使用更小的块 |
| Log Buffer Space | 增大LOG_BUFFER,改善I/O |
| Log File Switch | 增加或者增大日志文件 |
| Log file sync | 减小提交的频率;使用更快的I/O;或者使用裸设备 |
| Write complete waits | 增加DBWR;提高CKPT的频率; |
Top 5 Timed Events
~~~~~~~~~~~~~~~~~~ % Total
Event Waits Time (s) Ela Time
——————————————– ———— ———– ——–
CPU time 361 54.14
log file sync 74,324 101 15.22
enqueue 729 88 13.28
db file sequential read 7,303 65 9.76
SQL*Net message from dblink 482 20 3.05
Wait Events for DB: ORA92 Instance: ora92 Snaps: 13 -14
-> s - second
-> cs - centisecond - 100th of a second
-> ms - millisecond - 1000th of a second
-> us - microsecond - 1000000th of a second
-> ordered by wait time desc, waits desc (idle events last)
Avg
Total Wait wait Waits
Event Waits Timeouts Time (s) (ms) /txn
—————————- ———— ———- ———- —— ——–
log file sync 74,324 0 101 1 1.0
enqueue 729 0 88 121 0.0
db file sequential read 7,303 0 65 9 0.1
SQL*Net message from dblink 482 0 20 42 0.0
db file parallel write 725 0 14 19 0.0
db file scattered read 2,415 0 6 3 0.0
process startup 8 0 4 440 0.0
latch free 1,307 1,300 2 1 0.0
log file parallel write 67,042 0 2 0 0.9
control file sequential read 269 0 1 3 0.0
single-task message 24 0 1 33 0.0
control file parallel write 325 0 1 2 0.0
buffer busy waits 3,368 0 1 0 0.0
log file switch completion 19 0 0 20 0.0
direct path read 288 0 0 0 0.0
LGWR wait for redo copy 1,032 0 0 0 0.0
SQL*Net more data to client 1,390 0 0 0 0.0
kksfbc child completion 1 1 0 10 0.0
log file sequential read 2 0 0 5 0.0
direct path write 128 0 0 0 0.0
library cache pin 14 0 0 0 0.0
SQL*Net more data from dblin 4 0 0 0 0.0
log file single write 2 0 0 1 0.0
SQL*Net message to dblink 482 0 0 0 0.0
buffer deadlock 30 30 0 0 0.0
SQL*Net message from client 436,773 0 143,221 328 5.8
jobq slave wait 2,688 1,664 6,688 2488 0.0
wakeup time manager 27 27 791 29297 0.0
SQL*Net message to client 436,772 0 0 0 5.8
Background Wait Events for DB: ORA92 Instance: ora92 Snaps: 13 -14
-> ordered by wait time desc, waits desc (idle events last)
Avg
Total Wait wait Waits
Event Waits Timeouts Time (s) (ms) /txn
—————————- ———— ———- ———- —— ——–
db file parallel write 725 0 14 19 0.0
log file parallel write 67,044 0 2 0 0.9
control file sequential read 186 0 1 4 0.0
control file parallel write 325 0 1 2 0.0
db file scattered read 38 0 0 7 0.0
direct path read 288 0 0 0 0.0
LGWR wait for redo copy 1,032 0 0 0 0.0
db file sequential read 3 0 0 6 0.0
log file sequential read 2 0 0 5 0.0
direct path write 128 0 0 0 0.0
log file single write 2 0 0 1 0.0
rdbms ipc message 63,167 1,061 4,970 79 0.8
smon timer 3 3 879 ###### 0.0
pmon timer 292 292 823 2819 0.0
接下来的部分,是关于SQL的统计信息,分为6块来统计排序:
ordered by buffer gets
ordered by Physical reads
ordered by Executions
ordered by Parse Calls
ordered by Sharable Memory
ordered by Version Count
这一部分,通过Buffer Gets对SQL语句进行排序,即通过它执行了多少个逻辑I/O来排序。顶端的注释表明一个PL/SQL单元的缓存获得(Buffer Gets)包括被这个代码块执行的所有SQL语句的Buffer Gets。因此将经常在这个列表的顶端看到PL/SQL过程,因为存储过程执行的单独的语句的数目被总计出来。
在这里的Buffer Gets是一个累积值,所以这个值大并不一定意味着这条语句的性能存在问题。通常我们可以通过对比该条语句的Buffer Gets和physical reads值,如果这两个比较接近,肯定这条语句是存在问题的,我们可以通过执行计划来分析,为什么physical reads的值如此之高。另外,我们在这里也可以关注gets per exec的值,这个值如果太大,表明这条语句可能使用了一个比较差的索引或者使用了不当的表连接。
另外说明一点:大量的逻辑读往往伴随着较高的CPU消耗。所以很多时候我们看到的系统CPU将近100%的时候,很多时候就是SQL语句造成的,这时候我们可以分析一下这里逻辑读大的SQL。
SQL ordered by Gets for DB: ORA92 Instance: ora92 Snaps: 13 -14
-> End Buffer Gets Threshold: 10000
-> Note that resources reported for PL/SQL includes the resources used by
all SQL statements called within the PL/SQL code. As individual SQL
statements are also reported, it is possible and valid for the summed
total % to exceed 100
CPU Elapsd
Buffer Gets Executions Gets per Exec %Total Time (s) Time (s) Hash Value
————— ———— ————– —— ——– ——— ———-
13,367,435 171 78,172.1 68.3 259.36 353.19 3790040751
DECLARE job BINARY_INTEGER := :job; next_date DATE := :mydate;
broken BOOLEAN := FALSE; BEGIN P_DXH_DEALOVERTIMEDXHREC; :mydate
:= next_date; IF broken THEN :b := 1; ELSE :b := 0; END IF; END
……
这部分通过物理读对SQL语句进行排序。这显示引起大部分对这个系统进行读取活动的SQL,即物理I/O。当我们的系统如果存在I/O瓶颈时,需要关注这里I/O操作比较多的语句。
SQL ordered by Reads for DB: ORA92 Instance: ora92 Snaps: 13 -14
-> End Disk Reads Threshold: 1000
CPU Elapsd
Physical Reads Executions Reads per Exec %Total Time (s) Time (s) Hash Value
————— ———— ————– —— ——– ——— ———-
4,187 24 174.5 15.8 0.79 52.99 1895519470
DECLARE job BINARY_INTEGER := :job; next_date DATE := :mydate;
broken BOOLEAN := FALSE; BEGIN p_dxh_tmp_importUserInfo2(500); :
mydate := next_date; IF broken THEN :b := 1; ELSE :b := 0; END I
F; END;
538 21,504 0.0 2.0 5.92 241.61 1725988165
Module: Das.exe
begin P_DXH_AddSms(I_CALLERNO=>:V001,I_CALLEENO=>:V002,I_CALLTY
PE=>:V003,I_DXHHFLAG=>:V004,O_RET=>:V005);end;
……
这部分告诉我们在这段时间中执行次数最多的SQL语句。为了隔离某些频繁执行的查询,以观察是否有某些更改逻辑的方法以避免必须如此频繁的执行这些 查询,这可能是很有用的。或许一个查询正在一个循环的内部执行,而且它可能在循环的外部执行一次,可以设计简单的算法更改以减少必须执行这个查询的次数。 即使它运行的飞快,任何被执行几百万次的操作都将开始耗尽大量的时间。
SQL ordered by Executions for DB: ORA92 Instance: ora92 Snaps: 13 -14
-> End Executions Threshold: 100
CPU per Elap per
Executions Rows Processed Rows per Exec Exec (s) Exec (s) Hash Value
———— ————— —————- ———– ———- ———-
102,491 0 0.0 0.00 0.00 1053795750
Module: Das.exe
COMMIT
48,861 38,275 0.8 0.00 0.00 947217968
Module: Das.exe
SELECT T.AREAID FROM T_DXH_MOBILE S, T_DXH_AREA T WHERE S.MOBILE
SEGMENT = SUBSTR(:B1 ,1,7) AND T.AREACODE = S.AREACODE AND ROWNU
M = 1
在这一部分,主要显示PARSE与EXECUTIONS的对比情况。如果PARSE/EXECUTIONS>1,往往说明这个语句可能存在问 题:没有使用绑定变量,共享池设置太小,cursor_sharing被设置为exact,没有设置session_cached_cursors等等问 题。
SQL ordered by Parse Calls for DB: ORA92 Instance: ora92 Snaps: 13 -14
-> End Parse Calls Threshold: 1000
% Total
Parse Calls Executions Parses Hash Value
———— ———— ——– ———-
61,404 30,650 32.06 3303409220
Module: SvcProcessor.exe
begin P_DXH_UPDATESUBMITSTATUS(:V00001,:V00002,:V00003,:V00004);
end;
1,661 1,661 0.87 140223014
Module: SvcProcessor.exe
SELECT SERIALNO, PID, SERVICEID, SMSCONTENT, REPORTFLAG, ORGADDR
, DESTADDR, FEEADDR, FEETYPE, FEEUSERTYPE, FEECODE, SPID FROM T_
DXH_OPENDETECT WHERE LOCKFLAG = :B1
在这一部分,主要是针对shared memory占用的情况进行排序。
SQL ordered by Sharable Memory for DB: ORA92 Instance: ora92 Snaps: 13 -14
-> End Sharable Memory Threshold: 1048576
Sharable Mem (b) Executions % Total Hash Value
—————- ———— ——- ————
1,115,384 15,112 0.2 3531895589
Module: Das.exe
INSERT INTO T_DXH_DXHRECLOG (CALLERNO, CALLEENO, NOTIFYFLAG, SMS
TYPE, AREAID, LOGDATE) VALUES (:B4 , :B3 , 1, :B2 , :B1 , TO_CHA
R(SYSDATE, ‘MMDD’))
在这一部分,主要是针对SQL语句的多版本进行排序。相同的SQL文本,但是不同属性,比如对象owner不同,会话优化模式不同、类型不同、长度不同和绑定变量不同等等的语句,他们是不能共享的,所以再缓存中会存在多个不同的版本。这当然就造成了资源上的更多的消耗。
SQL ordered by Version Count for DB: ORA92 Instance: ora92 Snaps: 13 -14
-> End Version Count Threshold: 20
Version
Count Executions Hash Value
——– ———— ————
30 15,112 3531895589
Module: Das.exe
INSERT INTO T_DXH_DXHRECLOG (CALLERNO, CALLEENO, NOTIFYFLAG, SMS
TYPE, AREAID, LOGDATE) VALUES (:B4 , :B3 , 1, :B2 , :B1 , TO_CHA
R(SYSDATE, ‘MMDD’))
小结:
对于出现在上面的可疑的sql语句,我们可以查看语句相关的执行计划,然后分析相关索引等是否合理。
通过语句查看执行计划的方法:
SELECT id,parent_id,LPAD(’ ‘,4*(LEVEL-1))||operation||’ ‘||options||’ ‘||object_name “Execution plan” ,cost,cardinality,bytes
FROM (
SELECT p.* FROM v$sql_plan p,v$sql s WHERE p.address = s.ADDRESS
AND p.hash_value = s.HASH_VALUE
and p.hash_value = ‘&hash_value’
)
CONNECT BY PRIOR id = parent_id
START WITH id = 0;
查看,分析,优化索引等在这里就不再一一描述了。
这部分数据主要是从V$SYSSTAT表中统计出来的,一些条目的详细内容会在后面逐条标注。
Instance Activity Stats for DB: ORA92 Instance: ora92 Snaps: 13 -14
Statistic Total per Second per Trans
——————————— —————— ————– ————
CPU used by this session 36,055 42.8 0.5
CPU used when call started 9,526 11.3 0.1
CR blocks created 9,509 11.3 0.1
DBWR buffers scanned 12,962 15.4 0.2
DBWR checkpoint buffers written 87,437 103.7 1.2
DBWR checkpoints 1 0.0 0.0
DBWR free buffers found 12,700 15.1 0.2
DBWR lru scans 116 0.1 0.0
DBWR make free requests 124 0.2 0.0
DBWR summed scan depth 12,962 15.4 0.2
DBWR transaction table writes 23 0.0 0.0
DBWR undo block writes 18,974 22.5 0.3
PX local messages recv’d 0 0.0 0.0
PX local messages sent 0 0.0 0.0
SQL*Net roundtrips to/from client 436,777 518.1 5.8
SQL*Net roundtrips to/from dblink 482 0.6 0.0
active txn count during cleanout 8,651 10.3 0.1
background checkpoints completed 2 0.0 0.0
background checkpoints started 1 0.0 0.0
background timeouts 1,288 1.5 0.0
branch node splits 6 0.0 0.0
buffer is not pinned count 2,170,225 2,574.4 28.7
buffer is pinned count 2,694,289 3,196.1 35.6
bytes received via SQL*Net from c 35,743,183 42,400.0 472.8
bytes received via SQL*Net from d 123,793 146.9 1.6
bytes sent via SQL*Net to client 25,187,619 29,878.6 333.1
bytes sent via SQL*Net to dblink 76,754 91.1 1.0
calls to get snapshot scn: kcmgss 1,533,555 1,819.2 20.3
calls to kcmgas 149,646 177.5 2.0
calls to kcmgcs 10,190 12.1 0.1
change write time 762 0.9 0.0
cleanout - number of ktugct calls 13,095 15.5 0.2
cluster key scan block gets 424 0.5 0.0
cluster key scans 202 0.2 0.0
commit cleanout failures: block l 1 0.0 0.0
commit cleanout failures: buffer 18 0.0 0.0
commit cleanout failures: callbac 63 0.1 0.0
commit cleanout failures: cannot 2,087 2.5 0.0
commit cleanouts 643,505 763.4 8.5
commit cleanouts successfully com 641,336 760.8 8.5
commit txn count during cleanout 35,188 41.7 0.5
consistent changes 63,943 75.9 0.9
consistent gets 16,616,758 19,711.5 219.8
由consistent gets,db block gets和physical reads这三个值,我们也可以计算得到buffer hit ratio,计算的公式如下: buffer hit ratio = 100*(1-physical reads /(consistent gets+ db block gets)),例如在这里,我们可以计算得到:buffer hit ratio =100*(1-26524/(16616758+2941398))= 99.86
consistent gets - examination 1,168,584 1,386.2 15.5
current blocks converted for CR 0 0.0 0.0
cursor authentications 2 0.0 0.0
data blocks consistent reads - un 63,873 75.8 0.8
db block changes 2,596,938 3,080.6 34.4
db block gets 2,941,398 3,489.2 38.9
deferred (CURRENT) block cleanout 130,783 155.1 1.7
dirty buffers inspected 166 0.2 0.0
脏数据从LRU列表中老化,A value here indicates that the DBWR is not keeping up。如果这个值大于0,就需要考虑增加DBWRs。
dirty buffers inspected: This is the number of dirty (modified) data buffers that were aged out on the LRU list. You may benefit by adding more DBWRs.If it is greater than 0, consider increasing the database writes.
enqueue conversions 485 0.6 0.0
enqueue deadlocks 0 0.0 0.0
enqueue releases 318,825 378.2 4.2
enqueue requests 318,825 378.2 4.2
enqueue timeouts 0 0.0 0.0
Instance Activity Stats for DB: ORA92 Instance: ora92 Snaps: 13 -14
Statistic Total per Second per Trans
——————————— —————— ————– ————
enqueue waits 728 0.9 0.0
exchange deadlocks 30 0.0 0.0
execute count 1,004,280 1,191.3 13.3
free buffer inspected 188 0.2 0.0
这个值包含dirty,pinned,busy的buffer区域,如果free buffer inspected - dirty buffers inspected - buffer is pinned count的值还是比较大,表明不能被重用的内存块比较多,这将导致latch争用,需要增大buffer cache。
free buffer requested 116,422 138.1 1.5
hot buffers moved to head of LRU 17,750 21.1 0.2
immediate (CR) block cleanout app 1,916 2.3 0.0
immediate (CURRENT) block cleanou 81,385 96.5 1.1
index fast full scans (full) 0 0.0 0.0
index fetch by key 335,907 398.5 4.4
index scans kdiixs1 692,053 820.9 9.2
leaf node 90-10 splits 418 0.5 0.0
leaf node splits 1,941 2.3 0.0
logons cumulative 716 0.9 0.0
messages received 67,830 80.5 0.9
messages sent 67,830 80.5 0.9
no buffer to keep pinned count 0 0.0 0.0
no work - consistent read gets 14,240,381 16,892.5 188.4
opened cursors cumulative 84,306 100.0 1.1
parse count (failures) 6,074 7.2 0.1
parse count (hard) 6,090 7.2 0.1
parse count (total) 191,531 227.2 2.5
通过parse count (hard)和parse count (total),可以计算soft parse率为:
100-100*(parse count (hard)/parse count (total)) =100-100*(1-6090/191531)=96.82
parse time cpu 44 0.1 0.0
parse time elapsed 635 0.8 0.0
physical reads 26,524 31.5 0.4
physical reads direct 288 0.3 0.0
physical writes 87,993 104.4 1.2
physical writes direct 128 0.2 0.0
physical writes non checkpoint 29,010 34.4 0.4
pinned buffers inspected 0 0.0 0.0
prefetch clients - default 0 0.0 0.0
prefetched blocks 16,550 19.6 0.2
prefetched blocks aged out before 0 0.0 0.0
process last non-idle time 0 0.0 0.0
recursive calls 1,398,277 1,658.7 18.5
recursive cpu usage 27,349 32.4 0.4
redo blocks written 749,639 889.3 9.9
redo buffer allocation retries 13 0.0 0.0
redo entries 1,343,828 1,594.1 17.8
redo log space requests 19 0.0 0.0
redo log space wait time 38 0.1 0.0
redo ordering marks 0 0.0 0.0
redo size 355,818,888 422,086.5 4,706.2
redo synch time 10,483 12.4 0.1
redo synch writes 74,372 88.2 1.0
redo wastage 15,765,096 18,701.2 208.5
redo write time 6,171 7.3 0.1
redo writer latching time 3 0.0 0.0
redo writes 67,055 79.5 0.9
rollback changes - undo records a 250 0.3 0.0
rows fetched via callback 310,070 367.8 4.1
session connect time 0 0.0 0.0
session cursor cache count 1,818 2.2 0.0
session cursor cache hits 168,798 200.2 2.2
session logical reads 19,558,052 23,200.5 258.7
session pga memory 549,909,680 652,324.7 7,273.4
Instance Activity Stats for DB: ORA92 Instance: ora92 Snaps: 13 -14
Statistic Total per Second per Trans
——————————— —————— ————– ————
session pga memory max 1,185,992,768 1,406,871.6 15,686.5
session uga memory 3,015,076,014,672 ############## ############
session uga memory max 175,484,416 208,166.6 2,321.0
shared hash latch upgrades - no w 675,962 801.9 8.9
shared hash latch upgrades - wait 3,460 4.1 0.1
sorts (disks) 0 0 0
磁盘排序一般不能超过5%。如果超过5%,需要设置参数PGA_AGGREGATE_TARGET或者 SORT_AREA_SIZE,注意,这里SORT_AREA_SIZE是分配给每个用户的,PGA_AGGREGATE_TARGET则是针对所有的 session的一个总数设置。
sorts (memory) 180,293 213.9 2.4
内存中的排序数量
sorts (rows) 511,574 606.9 6.8
summed dirty queue length 430 0.5 0.0
switch current to new buffer 59,534 70.6 0.8
table fetch by rowid 2,094,274 2,484.3 27.7
这是通过索引或者where rowid=语句来取得的行数,当然这个值越大越好。
table fetch continued row 408 0.5 0.0
这是发生行迁移的行。当行迁移的情况比较严重时,需要对这部分进行优化。
检查行迁移的方法:
清除的方法:
方法1:create table table_name_tmp as select * from table_name where rowed in (select head_rowid from chained_rows);
Delete from table_name where rowed in (select head_rowid from chained_rows);
Insert into table_name select * from table_name_tmp;
方法2:create table table_name_tmp select * from table_name ;
truncate table table_name
insert into table_name select * from table_name_tmp
方法3:用exp工具导出表,然后删除这个表,最后用imp工具导入这表
方法4:alter table table_name move tablespace tablespace_name,然后再重新表的索引
上面的4种方法可以用以消除已经存在的行迁移现象,但是行迁移的产生很多情况下时由于PCT_FREE参数设置的太小所导致,所以需要调整PCT_FREE参数的值。
table scan blocks gotten 299,249 355.0 4.0
table scan rows gotten 1,912,851 2,269.1 25.3
table scans (long tables) 0 0.0 0.0
longtables就是表的大小超过buffer buffer* _SMALL_TABLE_THRESHOLD的表。如果一个数据库的大表扫描过多,那么db file scattered read等待事件可能同样非常显著。如果table scans (long tables)的per Trans值大于0,你可能需要增加适当的索引来优化你的SQL语句。
table scans (short tables) 143,830 170.6 1.9
short tables是指表的长度低于buffer chache 2%(2%是有隐含参数_SMALL_TABLE_THRESHOLD定义的,这个参数在oracle不同的版本中,有不同的含义。在9i和10g中,该 参数值定义为2%,在8i中,该参数值为20个blocks,在v7中,该参数为5个blocks)的表。这些表将优先使用全表扫描。一般不使用索引。 _SMALL_TABLE_THRESHOLD值的计算方法如下(9i,8K): (db_cache_size/8192)*2%。
注意:_SMALL_TABLE_THRESHOLD参数修改是相当危险的操作。
transaction rollbacks 70 0.1 0.0
transaction tables consistent rea 0 0.0 0.0
transaction tables consistent rea 0 0.0 0.0
user calls 345,054 409.3 4.6
user commits 75,587 89.7 1.0
user rollbacks 19 0.0 0.0
workarea executions - optimal 247,121 293.1 3.3
write clones created in backgroun 0 0.0 0.0
write clones created in foregroun 25 0.0 0.0
下面两个报表是面向I/O的。通常,在这里期望在各设备上的读取和写入操作是均匀分布的。要找出什么文件可能非常”热”。一旦DBA了解了如何读取和写入这些数据,他们也许能够通过磁盘间更均匀的分配I/O而得到某些性能提升。
在这里主要关注Av Rd(ms)列 (reads per millisecond)的值,一般来说,大部分的磁盘系统的这个值都能调整到14ms以下,oracle认为该值超过20ms都是不必要的。如果该值超 过1000ms,基本可以肯定存在I/O的性能瓶颈。如果在这一列上出现######,可能是你的系统存在严重的I/O问题,也可能是格式的显示问题。
当出现上面的问题,我们可以考虑以下的方法:
1)优化操作该表空间或者文件的相关的语句。
2)如果该表空间包含了索引,可以考虑压缩索引,是索引的分布空间减小,从而减小I/O。
3)将该表空间分散在多个逻辑卷中,平衡I/O的负载。
4)我们可以通过设置参数DB_FILE_MULTIBLOCK_READ_COUNT来调整读取的并行度,这将提高全表扫描的效率。但是也会带来 一个问题,就是oracle会因此更多的使用全表扫描而放弃某些索引的使用。为解决这个问题,我们需要设置另外一个参数 OPTIMIZER_INDEX_COST_ADJ=30(一般建议设置10-50)。
关于OPTIMIZER_INDEX_COST_ADJ=n:该参数是一个百分比值,缺省值为100,可以理解为FULL SCAN COST/INDEX SCAN COST。当n%* INDEX SCAN COST 5)检查并调整I/O设备的性能。 Tablespace IO Stats for DB: ORA92 Instance: ora92 Snaps: 13 -14 ->ordered by IOs (Reads + Writes) desc Tablespace —————————— Av Av Av Av Buffer Av Buf Reads Reads/s Rd(ms) Blks/Rd Writes Writes/s Waits Wt(ms) ————– ——- —— ——- ———— ——– ———- —— ICD_DXH_IDX 3,869 5 8.6 1.0 36,701 44 1,180 0.1 ICD_DXH_DAT 2,572 3 9.7 1.0 16,545 20 1,076 0.2 UNDOTBS1 16 0 86.9 1.0 19,084 23 283 0.0 ICD_DXH_HISIDX 689 1 30.8 1.0 14,953 18 108 0.0 ICD_DXH_HISDAT 2,756 3 7.9 7.3 1,082 1 3 0.0 PERFSTAT 215 0 6.0 1.0 193 0 0 0.0 SYSTEM 55 0 11.5 5.0 17 0 717 0.1 INDX 1 0 40.0 1.0 1 0 0 0.0 TOOLS 1 0 40.0 1.0 1 0 0 0.0 USERS 1 0 40.0 1.0 1 0 0 0.0 ————————————————————- File IO Stats for DB: ORA92 Instance: ora92 Snaps: 13 -14 ->ordered by Tablespace, File Tablespace Filename ———————— —————————————————- Av Av Av Av Buffer Av Buf Reads Reads/s Rd(ms) Blks/Rd Writes Writes/s Waits Wt(ms) ————– ——- —— ——- ———— ——– ———- —— ICD_DXH_DAT /dev/rlv_data001 377 0 9.4 1.0 1,640 2 321 0.2 /dev/rlv_data002 327 0 9.0 1.0 1,630 2 169 0.0 /dev/rlv_data003 313 0 10.0 1.0 1,718 2 87 0.0 /dev/rlv_data004 357 0 9.9 1.0 1,661 2 86 0.0 /dev/rlv_data005 400 0 11.5 1.0 1,627 2 128 0.2 /dev/rlv_data006 389 0 8.5 1.0 6,700 8 126 0.0 /dev/rlv_data007 409 0 9.6 1.0 1,569 2 159 0.7 这里将buffer poll细分,列举default、keep、recycle三种类型的buffer的详细情况。在这份报告中,我们的系统中只使用Default size的buffer pool。这里的3个waits统计,其实在前面的等待时间中已经包含,所以可以参考前面的描述。关于命中率也已经在前面讨论。 所以,其实这段信息不需要怎么关注。 Buffer Pool Statistics for DB: ORA92 Instance: ora92 Snaps: 13 -14 -> Standard block size Pools D: default, K: keep, R: recycle -> Default Pools for other block sizes: 2k, 4k, 8k, 16k, 32k Free Write Buffer Number of Cache Buffer Physical Physical Buffer Complete Busy P Buffers Hit % Gets Reads Writes Waits Waits Waits — ———- —– ———– ———– ———- ——- ——– —— D 635,200 99.9 19,556,815 26,990 88,450 0 0 3,368 这部分主要是关于实例的恢复的一些统计信息,也不需要怎么关注。 Instance Recovery Stats for DB: ORA92 Instance: ora92 Snaps: 13 -14 -> B: Begin snapshot, E: End snapshot Targt Estd Log File Log Ckpt Log Ckpt MTTR MTTR Recovery Actual Target Size Timeout Interval (s) (s) Estd IOs Redo Blks Redo Blks Redo Blks Redo Blks Redo Blks - —– —– ———- ———- ———- ———- ———- ———- B 300 70 54311 452198 450720 450720 1224858 E 300 69 53127 452947 450720 450720 1472619 这是oracle的对buffer pool的大小的调整建议。从advisory的数据看,当然buffer是越大,物理读更小,随着buffer的增大,对物理读的性能改进越来越小。当 前buffer 设置为5,120M,物理读因子=1。我们可以看到,buffer pool在3G之前的扩大,对物理读的改善非常明显,之后,这种改善的程度越来越低。 Buffer Pool Advisory for DB: ORA92 Instance: ora92 End Snap: 14 -> Only rows with estimated physical reads >0 are displayed -> ordered by Block Size, Buffers For Estimate (default block size first) Size for Size Buffers for Est Physical Estimated P Estimate (M) Factr Estimate Read Factor Physical Reads — ———— —– —————- ————- —————— D 512 .1 63,520 9.85 245,880,558 D 1,024 .2 127,040 5.41 134,932,093 D 1,536 .3 190,560 3.38 84,471,707 D 2,048 .4 254,080 2.41 60,240,471 D 2,560 .5 317,600 1.86 46,399,611 D 3,072 .6 381,120 1.54 38,365,243 D 3,584 .7 444,640 1.32 33,017,978 D 4,096 .8 508,160 1.18 29,353,901 D 4,608 .9 571,680 1.07 26,763,133 D 5,120 1.0 635,200 1.00 24,962,078 D 5,632 1.1 698,720 0.95 23,661,399 D 6,144 1.2 762,240 0.91 22,672,122 D 6,656 1.3 825,760 0.88 21,902,502 D 7,168 1.4 889,280 0.85 21,277,585 D 7,680 1.5 952,800 0.83 20,755,944 D 8,192 1.6 1,016,320 0.81 20,331,009 D 8,704 1.7 1,079,840 0.80 19,949,127 D 9,216 1.8 1,143,360 0.78 19,563,065 D 9,728 1.9 1,206,880 0.77 19,226,351 D 10,240 2.0 1,270,400 0.76 18,948,622 这里的buffer等待往往带来data block的比较大的等待。这部分等待的情况在前面等待事件中已经作过描述。 Buffer wait Statistics for DB: ORA92 Instance: ora92 Snaps: 13 -14 -> ordered by wait time desc, waits desc Tot Wait Avg Class Waits Time (s) Time (ms) —————— ———– ———- ——— data block 3,086 0 0 undo block 196 0 0 undo header 87 0 0 1st level bmb 3 0 0 2nd level bmb 1 0 0 这一部分主要展现的是PGA使用的情况,我们可以根据具体的情况通过设置参数PGA_AGGREGATE_TARGET来调整PGA的值。 在这里,设置的pga_aggregate_target=500M,并发数大概为270。而且数据库设置为 DEDICATED模式,在这种情况下,PGA要求有更大的空间,因为在PGA下需要存放stack space,user serssion data,cursor state信息。 通过下面的两个信息,我们可以看到当前的设置下,PGA Cache Hit达到了100%,所有的操作都是内存中完成的。 PGA Aggr Target Stats for DB: ORA92 Instance: ora92 Snaps: 13 -14 -> B: Begin snap E: End snap (rows dentified with B or E contain data which is absolute i.e. not diffed over the interval) -> PGA cache hit % - percentage of W/A (WorkArea) data processed only in-memory -> Auto PGA Target - actual workarea memory target -> W/A PGA Used - amount of memory used for all Workareas (manual + auto) -> %PGA W/A Mem - percentage of PGA memory allocated to workareas -> %Auto W/A Mem - percentage of workarea memory controlled by Auto Mem Mgmt -> %Man W/A Mem - percentage of workarea memory under manual control PGA Cache Hit % W/A MB Processed Extra W/A MB Read/Written ————— —————- ————————- 100.0 2,421 0 %PGA %Auto %Man PGA Aggr Auto PGA PGA Mem W/A PGA W/A W/A W/A Global Mem Target(M) Target(M) Alloc(M) Used(M) Mem Mem Mem Bound(K) - ——— ——— ———- ———- —— —— —— ———- B 500 354 216.3 0.0 .0 .0 .0 25,600 E 500 355 214.4 0.0 .0 .0 .0 25,600 PGA Aggr Target Histogram for DB: ORA92 Instance: ora92 Snaps: 13 -14 -> Optimal Executions are purely in-memory operations Low High Optimal Optimal Total Execs Optimal Execs 1-Pass Execs M-Pass Execs ——- ——- ————– ————- ———— ———— 8K 16K 246,058 246,058 0 0 16K 32K 104 104 0 0 32K 64K 1 1 0 0 64K 128K 3 3 0 0 128K 256K 2 2 0 0 256K 512K 2 2 0 0 512K 1024K 1 1 0 0 2M 4M 4 4 0 0 PGA_AGGREGATE_TARGET参数的调整建议。 我们可以看到,在advisory中,当PGA_AGGREGATE_TARGET达到500M时,再增大PGA_AGGREGATE_TARGET,基本已经起不到提升性能的作用了。 PGA Memory Advisory for DB: ORA92 Instance: ora92 End Snap: 14 -> When using Auto Memory Mgmt, minimally choose a pga_aggregate_target value where Estd PGA Overalloc Count is 0 Estd Extra Estd PGA Estd PGA PGA Target Size W/A MB W/A MB Read/ Cache Overalloc Est (MB) Factr Processed Written to Disk Hit % Count ———- ——- —————- —————- ——– ———- 63 0.1 4,398,132.4 17,448.1 100.0 34,943 125 0.3 4,398,132.4 4,267.6 100.0 47 250 0.5 4,398,132.4 435.8 100.0 0 375 0.8 4,398,132.4 382.9 100.0 0 500 1.0 4,398,132.4 0.0 100.0 0 600 1.2 4,398,132.4 0.0 100.0 0 700 1.4 4,398,132.4 0.0 100.0 0 800 1.6 4,398,132.4 0.0 100.0 0 900 1.8 4,398,132.4 0.0 100.0 0 1,000 2.0 4,398,132.4 0.0 100.0 0 1,500 3.0 4,398,132.4 0.0 100.0 0 2,000 4.0 4,398,132.4 0.0 100.0 0 3,000 6.0 4,398,132.4 0.0 100.0 0 4,000 8.0 4,398,132.4 0.0 100.0 0 关于Enqueue,我们在等待事件里面已经作了比较详尽的描述,这里只是对等待事件的一个展开描述,分项的含义请参考在等待事件的说明。 Enqueue activity for DB: ORA92 Instance: ora92 Snaps: 13 -14 -> Enqueue stats gathered prior to 9i should not be compared with 9i data -> ordered by Wait Time desc, Waits desc Avg Wt Wait Eq Requests Succ Gets Failed Gets Waits Time (ms) Time (s) – ———— ———— ———– ———– ————- ———— TX 81,127 81,263 0 674 134.32 91 SQ 2,032 2,032 0 53 .25 0 HW 107 107 0 1
8、Buffer Pool统计信息
9、实例的恢复情况统计信息
10、Buffer Pool调整的Advisory
11、Buffer Pool等待情况统计
12、PGA统计信息
13、PGA调整的Advisory
14、队列的统计信息
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/82387/viewspace-1016311/ ,如需转载,请注明出处,否则将追究法律责任。