数据库性能报告(awr)共取样了4份,我们主要分析比较典型的,能反映数据库运行状态的报告进行分析。从此报告来看,数据库响应正常。以下分别从各个角度进行分析。

一、抽样时间
DB Name DB Id Instance Inst num Release RAC Host
SITEDB 203036004 sitedb 1 10.2.0.3.0 NO sitedb1
Snap Id Snap Time Sessions Cursors/Session
Begin Snap: 19429 24-Feb-11 09:00:33 43 4.4
End Snap: 19437 24-Feb-11 17:00:50 43 3.9
Elapsed: 480.29 (mins)
DB Time: 10.64 (mins)
 分析:
sitedb在长达8小时的性能采样时间中,session数为43个,每个session打开的cursors为4个,反应出数据库并发度不高。数据库消耗时间(DB Time)为10.64分,可以看出数据库在取样的时间里平均消耗操作资源及其有限,操作系统资源不会成为数据库运行缓慢的瓶颈。

二、数据库负载
Cache Sizes
Begin End
Buffer Cache: 512M 512M Std Block Size: 8K
Shared Pool Size: 976M 976M Log Buffer: 14,356K
Load Profile
Per Second Per Transaction
Redo size: 7,725.75 56,051.19
Logical reads: 684.35 4,965.02
Block changes: 46.80 339.54
Physical reads: 388.82 2,820.94
Physical writes: 1.84 13.34
User calls: 8.66 62.83
Parses: 3.30 23.97
Hard parses: 0.05 0.37
Sorts: 2.53 18.34
Logons: 0.02 0.17
Executes: 12.48 90.58
Transactions: 0.14
% Blocks changed per Read: 6.84 Recursive Call %: 76.65
Rollback per transaction %: 0.00 Rows per Sort: 156.65
Instance Efficiency Percentages (Target 100%)
Buffer Nowait %: 100.00 Redo NoWait %: 100.00
Buffer Hit %: 43.19 In-memory Sort %: 100.00
Library Hit %: 98.92 Soft Parse %: 98.46
Execute to Parse %: 73.54 Latch Hit %: 100.00
Parse CPU to Parse Elapsd %: 21.95 % Non-Parse CPU: 99.88
Shared Pool Statistics
Begin End
Memory Usage %: 72.44 75.60
% SQL with executions>1: 99.20 98.13
% Memory for SQL w/exec>1: 93.62 93.00

 分析:
在设置了sga_target=1610612736的前提下,buffer cache和shared pool size均保持不变,反应出数据库内存组件大小足够,数据库运行稳定。
1、 从buffer cache角度分析:结合三项指标Logical reads,Physical reads,Buffer Hit %,(在不考虑direct read的情况下,Logical reads=684.35次,其中Physical reads占了388.82次,Buffer Hit %=43.19),可以看出整个系统全表扫描比较严重,但并没有引起数据库cache buffer latch的争用或者等待(Buffer Nowait %=100)。
2、 从shared pool角度分析:结合三项指标Parses,Hard parses,Library Hit %,Soft Parse %(Parses=3.30/s,其中Hard parses为0.05/s, Library Hit %=98.92),可以看出shared pool负载较轻,而且Soft Parse %和Latch Hit %分别达到了98.46%和100%,在没有baseline的前提下,指标非常理想。

SGA Target Advisory
SGA Target Size (M) SGA Size Factor Est DB Time (s) Est Physical Reads
768 0.50 114,628 1,867,202,139
1,152 0.75 102,325 1,815,496,678
1,536 1.00 102,264 1,814,226,719
1,920 1.25 101,006 1,815,315,255
2,304 1.50 100,955 1,814,045,296
2,688 1.75 100,536 1,804,611,317
3,072 2.00 100,536 1,804,611,317

 分析:
由以上指标可以看出,目前sga_target=1,536M,但增大此参数对减少物理IO,提高buffer cache命中率并没有多大用处。
PGA Target Advisory

Low Optimal High Optimal Total Execs Optimal Execs 1-Pass Execs M-Pass Execs
2K 4K 55,750 55,750 0 0
64K 128K 266 266 0 0
128K 256K 62 62 0 0
256K 512K 49 49 0 0
512K 1024K 430 430 0 0
1M 2M 56 56 0 0
2M 4M 14 14 0 0
4M 8M 3 3 0 0
16M 32M 1 1 0 0
 分析:
在pga_aggregate_target=606076928的前提下,Oracle进行磁盘排序为0(1-Pass Execs和M-Pass Execs均为0)
三、等待事件
Top 5 Timed Events
Event Waits Time(s) Avg Wait(ms) % Total Call Time Wait Class
CPU time 588 92.1
db file scattered read 725,872 55 0 8.7 User I/O
Log archive I/O 308 20 66 3.2 System I/O
db file sequential read 87,491 10 0 1.6 User I/O
log file parallel write 26,148 9 0 1.5 System I/O
Wait Events
• 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)
Event Waits %Time -outs Total Wait Time (s) Avg wait (ms) Waits /txn
Log archive I/O 308 0.00 20 66 0.08

 分析:
在长达8小时的统计中,以上等待事件中db file scattered read比例比较大,也反映出系统可能full table ssan或者index fast scan较多,但是等待时间较小(Time(s)=55秒,Avg Wait(ms)=0),可以不需关注。
平均事务响应时间=(66ms*0.08)/0.032=165ms,从采样时间来看,平均事务响应时间非常迅速,在没有baseline的前提下,系统响应正常。

附:获取数据库全表扫描语句
注意:由于此脚本需要解析SQL语句,最好在数据库空闲时段进行。
create table full_sql (sql_text varchar2(1000), executions number);
create or replace procedure p_findfullsql as

v_csr number;
v_rc number;
v_string varchar2(2000);

v_count number;


cursor c1 is select sql_text,executions from v$sqlarea where lower(sql_text) like '%select%';

begin

for x1 in c1 loop

delete from plan_table ;
Begin
v_Csr := DBMS_SQL.OPEN_CURSOR;
v_string := 'explain plan for ' ;
v_string := v_string||x1.sql_text ;
DBMS_SQL.PARSE(v_csr, v_string, DBMS_SQL.V7);
v_rc := DBMS_SQL.EXECUTE(v_csr);
DBMS_SQL.CLOSE_CURSOR(v_csr);
Exception
when others then
null;
End ;

select count(*) into v_count from plan_table where options like '%FULL%' and operation like '%TABLE%' ;
if v_count > 0 then
insert into full_sql(sql_text,executions) values (x1.sql_text, x1.executions) ;
end if;
end loop ;
commit;
end ;
/
execute p_findfullsql ;
select * from full_sql;


通过select * from full_sql;可以知道执行全表扫描的语句,加以着重研究,比如可以讲小表放入keep_buffer,让其常驻内存