/* 报表头信息,数据库实例相关信息,包括数据库名称、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