如何使用AWR报告来诊断数据库性能问题 (Doc ID 1523048.1)

0    514    2

Tags:

👉 本文共约209026个字,系统预计阅读时间或需786分钟。

【性能调优】Oracle AWR报告指标全解析

原文:https://mp.weixin.qq.com/s/O3R4kcbO7J8LQxRQhIWgWw

1、报告总结

WORKLOAD REPOSITORY report for

DB NameDB IdInstanceInst numStartup TimeReleaseRAC
CUFS3961207481cufs124-Aug-19 21:0811.2.0.4.0NO
Host NamePlatformCPUsCoresSocketsMemory (GB)
databaseLinux x86 64-bit1616431.48
Snap IdSnap TimeSessionsCursors/Session
Begin Snap:951204-Dec-19 10:00:20859.3
End Snap:951304-Dec-19 11:00:28803.4
Elapsed:60.14 (mins)
DB Time:64.77 (mins)

Elapsed为该AWR性能报告的时间跨度(自然时间的跨度,例如前一个快照snapshot是9点生成的,后一个快照snapshot是11点生成的,

则若使用@?/rdbms/admin/awrrpt 脚本中指定这2个快照的话,那么其elapsed = (11-9)=2 个小时)

一个AWR性能报告至少需要2个AWR snapshot性能快照才能生成 ( 这2个快照时间实例不能重启过,否则指定这2个快照生成AWR性能报告会报错),

DB TIME= 所有前台session花费在database调用上的总和时间:

注意是前台进程foreground sessions
包括CPU时间、IO Time、和其他一系列非空闲等待时间

DB TIME 不等于 响应时间,DB TIME高了未必响应慢,DB TIME低了未必响应快

DB Time描绘了数据库总体负载,但要和elapsed time结合其来。

Average Active Session AAS= DB time/Elapsed Time
DB Time =60min,Elapsed Time =60min AAS=60/60=1 负载一般
DB Time= 1min,Elapsed Time= 60min AAS= 1/60 负载很轻
DB Time= 60000min,Elapsed Time=60min AAS=1000 系统hang住
DB TIME= DB CPU + Non-Idle Wait + Wait on CPU queue

如果仅有2个逻辑CPU,而2个session在60分钟都没等待事件,一直跑在CPU上,那么:

DB CPU=260mins , DB Time =260 +0 +0 =120
AAS = 120/60=2 正好等于OS load 2。
如果有3个session都100%仅消耗CPU,那么总有一个要wait on queue
DB CPU =2* 60mins ,wait on CPU queue=60mins
AAS= (120+ 60)/60=3 主机load 亦为3,

此时vmstat 看waiting for run time

1-1 内存参数大小

Cache Sizes

BeginEnd
Buffer Cache:2,880M2,880MStd Block Size:8K
Shared Pool Size:4,782M4,796MLog Buffer:4,356K

1-2 Load Profile

Load Profile

Per SecondPer TransactionPer ExecPer Call
DB Time(s):1.10.00.000.00
DB CPU(s):1.10.00.000.00
Redo size (bytes):35,814.6140.3
Logical read (blocks):22,708.388.9
Block changes:230.30.9
Physical read (blocks):395.71.6
Physical write (blocks):4.60.0
Read IO requests:8.70.0
Write IO requests:2.30.0
Read IO (MB):3.10.0
Write IO (MB):0.00.0
User calls:2,795.211.0
Parses (SQL):635.82.5
Hard parses (SQL):20.90.1
SQL Work Area (MB):2.70.0
Logons:0.10.0
Executes (SQL):641.82.5
Rollbacks:252.31.0
Transactions:255.3

指标含义

redo size单位bytes,redosize可以用来估量update/insert/delete的频率,大的redo size往往对lgwr写日志,和arch归档造成I/O压力,

Per Transaction可以用来分辨是大量小事务,还是少量大事务。如上例每秒redo 约1MB,每个事务800 字节,符合OLTP特征

Logical Read 单位(次数*块数),逻辑读耗CPU,主频和CPU核数都很重要,逻辑读高则DB CPU往往高,也往往可以看到latch: cache buffer chains等待。

Block changes 单位(次数*块数),描绘数据变化频率

Physical Read 单位(次数*块数),物理读消耗IO读,体现在IOPS和吞吐量等不同纬度上;但减少物理读可能意味着消耗更多CPU。
好的存储 每秒物理读能力达到几GB,例如Exadata。这个physical read包含了physical reads cache和physical reads direct

Physical writes 单位(次数*块数),主要是DBWR写datafile,也有direct path write。dbwr长期写出慢会导致定期log file switch(checkpoint no complete) 检查点无法完成的前台等待。 这个physical write 包含了physical writes direct +physical writes from cache

User Calls 单位次数,用户调用数,more details from internal

Parses 解析次数,包括软解析+硬解析,软解析优化得不好,则夸张地说几乎等于每秒SQL执行次数。即执行解析比1:1,而我们希望的是解析一次到处运行

Hard Parses 万恶之源:Cursor pin s on X, library cache: mutex X , latch: row cache objects /shared pool……………..。硬解析最好少于每秒20次

W/A MB processed 单位MB W/A workarea workarea中处理的数据数量,结合 In-memory Sort%

Logons 登陆次数, 结合AUDIT审计数据一起看。

Executes 执行次数,反应执行频率

Rollback 回滚次数,反应回滚频率,但是这个指标不太精确,

Transactions 每秒事务数,是数据库层的TPS,可以看做压力测试或比对性能时的一个指标,孤立看无意义

% Blocks changed per Read 每次逻辑读导致数据块变化的比率;如果’redo size’, ‘block changes’ ‘pct of blocks changed per read’三个指标都很高,则说明系统正执行大量insert/update/delete;pct of blocks changed per read = (block changes ) /( logical reads)

Recursive Call % 递归调用的比率;Recursive Call% = (recursive calls)/(user calls)

Rollback per transaction % 事务回滚比率。Rollback per transaction %= (rollback)/(transactions)
Rows per Sort平均每次排序涉及到的行数;Rows per Sort=(sorts(rows) ) / ( sorts(disk) + sorts(memory))

注意这些Load Profile负载指标在本环节提供了2个维度per second和per transaction。

per Second: 主要是把快照内的时间值除以快照时间的秒数,例如在A快照中V$SYSSTAT视图反应 table scans (long tables) 这个指标是 100 ,
在B快照中V$SYSSTAT视图反应 table scans (long tables) 这个指标是 3700, 而A快照和B快照之间间隔了一个小时3600秒,则对于table scans (long tables) per second 就是 ( 3700- 100) /3600=1。

per transaction : 基于事务的维度,与per second相比是把除数从时间的秒数改为了该段时间内的事务数。这个维度的很大用户是用来识别应用特性的变化

若2个AWR性能报告中该维度指标 出现了大幅变化,例如 redo size从本来per transaction 1k变化为 10k per transaction,则说明SQL业务逻辑肯定发生了某些变化。

注意AWR中的这些指标 并不仅仅用来孤立地了解 Oracle数据库负载情况, 实施调优工作。对于 故障诊断 例如HANG、Crash等, 完全可以通过对比问题时段的性能报告和常规时间来对比,通过各项指标的对比往往可以找出 病灶所在。

1-3 Instance Efficiency Percentages (Target 100%

Instance Efficiency Percentages (Target 100%)

Buffer Nowait %:100.00Redo NoWait %:100.00
Buffer Hit %:100.00In-memory Sort %:100.00
Library Hit %:90.16Soft Parse %:96.72
Execute to Parse %:0.93Latch Hit %:99.94
Parse CPU to Parse Elapsd %:75.79% Non-Parse CPU:87.28


上述所有指标的目标均为100%,越大越好

80%以上 %Non-Parse CPU
90%以上 Buffer Hit%, In-memory Sort%, Soft Parse%
95%以上 Library Hit%, Redo Nowait%, Buffer Nowait%
98%以上 Latch Hit%

1、Buffer Nowait % session申请一个buffer(兼容模式)不等待的次数比例。需要访问buffer时立即可以访问的比率,

不合理的db_cache_size,或者是SGA自动管理ASMM /Memory自动管理AMM下都可能因为db_cache_size过小引起大量的db file sequential /scattered read等待事件;
此外与 buffer HIT%相关的指标值得关注的还有 table scans(long tables) 大表扫描这个统计项目、此外相关的栏目还有Buffer Pool Statistics 、Buffer Pool Advisory等

3、Redo nowait%: session在生成redo entry时不用等待的比例,redo相关的资源争用例如redo space request争用可能造成生成redo时需求等待。此项数据来源于v$sysstat中的(redo log space requests/redo entries)。一般来说10g以后不太用关注log_buffer参数的大小,需要关注是否有十分频繁的 log switch ;过小的redo logfile size 如果配合较大的SGA和频繁的commit提交都可能造成该问题。考虑增到redo logfile 的尺寸 : 1-2G 每个,10-15组都是合适的。同时考虑优化redo logfile和datafile 的I/O。

4、In-memory Sort%:这个指标因为它不计算workarea中所有的操作类型,纯粹在内存中完成的排序比例。

5、Library Hit%: library cache命中率,申请一个library cache object例如一个SQL cursor时,其已经在library cache中的比例。合理值:>95% ,ns

6、Soft Parse: 软解析比例,经典指标,合理值>95%
Soft Parse %是AWR中另一个重要的解析指标,该指标反应了快照时间内软解析次数和总解析次数 (soft+hard 软解析次数+硬解析次数)的比值,若该指标很低,那么说明了可能存在剧烈的hard parse硬解析,大量的硬解析会消耗更多的CPU时间片并产生解析争用(此时可以考虑使用cursor_sharing=FORCE);
理论上我们总是希望 Soft Parse % 接近于100%, 但并不是说100%的软解析就是最理想的解析状态,通过设置 session_cached_cursors参数和反复重用游标我们可以让解析来的更轻量级,即通俗所说的利用会话缓存游标实现的软软解析(soft soft parse)。

7、Execute to Parse%指标反映了执行解析比其公式为 1-(parse/execute) , 目标为100% 及接近于只执行而不解析。在oracle中解析往往是执行的先提工作,但是通过游标共享可以解析一次执行多次,

执行解析可能分成多种场景:
hard coding => 代码硬解析一次,执行一次,理论上其执行解析比为 1:1 ,则理论上Execute to Parse =0 极差,且soft parse比例也为0%
绑定变量但是仍软解析=》软解析一次,执行一次 ,这种情况虽然比前一种好 但是执行解析比(这里的parse,包含了软解析和硬解析)仍是1:1, 理论上Execute to Parse =0 极差,但是soft parse比例可能很高
使用静态SQL、动态绑定、session_cached_cursor、open cursors等技术实现的解析一次,执行多次,执行解析比为N:1,则Execute to Parse= 1- (1/N) 执行次数越多Execute to Parse越接近100%,这种是我们在OLTP环境中希望看到的。
通俗地说 soft parse% 反映了软解析率, 而软解析在oracle中仍是较昂贵的操作, 我们希望的是解析1次执行N次,如果每次执行均需要软解析,那么虽然soft parse%=100% 但是parse time仍可能是消耗DB TIME的大头。
Execute to Parse反映了执行解析比,Execute to Parse和soft parse% 都很低那么说明确实没有绑定变量,而如果 soft parse%接近99%而Execute to Parse 不足90% 则说明没有执行解析比低,需要通过静态SQL、动态绑定、session_cached_cursor、open cursors等技术减少软解析。

8、Latch Hit%: willing-to-wait latch闩申请不要等待的比例。

9、Parse CPU To Parse Elapsd:该指标反映了快照内解析CPU时间和总的解析时间的比值(Parse CPU Time/ Parse Elapsed Time);若该指标水平很低,那么说明在整个解析过程中 实际在CPU上运算的时间是很短的,而主要的解析时间都耗费在各种其他非空闲的等待事件上了(如latch:shared pool,row cache lock之类等)

10、%Non-Parse CPU非解析cpu比例,公式为 (DB CPU – Parse CPU)/DB CPU,

1-5 Top 10 Foreground Events by Total Wait Time

Top 10 Foreground Events by Total Wait Time

EventWaitsTotal Wait Time (sec)Wait Avg(ms)% DB timeWait Class
DB CPU3823.198.4
log file sync10,933101.592.6Commit
cursor: pin S3,29923.47.6Concurrency
SQL*Net message to client7,835,07613.30.3Network
latch: shared pool7739.913.3Concurrency
direct path read29,4394.20.1User I/O
library cache: mutex X6813.15.1Concurrency
cursor: pin S wait on X732.636.1Concurrency
latch: row cache objects5442.34.1Concurrency
SQL*Net more data to client122,90020.1Network

丰富的等待事件以足够的细节来描绘系统运行的性能瓶颈(Mysql梦寐以求的)
Waits : 该等待事件发生的次数

Times : 该等待事件消耗的总计时间,单位为秒,对于DB CPU而言是前台进程所消耗CPU时间片的总和

Avg Wait(ms) :该等待事件平均等待的时间,实际就是Times/Waits,单位ms,

Wait Class: 等待类型:
Concurrency,SystemI/O,UserI/O,Administrative,Other,Configuration,Scheduler,Cluster,Application,Idle,Network,Commit

常见的等待事件

=========================>

1、db file scattered read:

Avg wait time应当小于20ms如果数据库执行全表扫描或者是全索引扫描会执行 Multi block I/O ,此时等待物理I/O 结束会出现此等待事件。一般从应用程序(SQL),I/O 方面入手调整; 注意和index fast full scans (full) 以及 table scans结合起来一起看。

2、db file sequential read:

该等待事件Avg wait time平均单次等待时间应当小于20ms

db file sequential read单块读等待是一种最为常见的物理IO等待事件,这里的sequential指的是将数据块读入到相连的内存空间中,而不是指所读取的数据块是连续的。

3、latch free:

其实是未获得latch 而进入latch sleep

4、enq:XX 队列锁等待:

视乎不同的队列锁有不同的情况:

Oracle队列锁: Enqueue HW

enq: TX – row lock/index contention等待事件

enq: TT – contention等待事件

enq: JI – contention等待事件

enq: US – contention等待事件

enq: TM – contention等待事件

enq: RO fast object reuse等待事件

enq: HW – contention等待事件

5、free buffer waits:

是由于无法找到可用的buffer cache 空闲区域,需要等待DBWR 写入完成引起

一般是由于低效的sql、过小的buffer cache、DBWR 工作负荷过量引起,

6、buffer busy wait/ read by other session:

以上2个等待事件可以归为一起处理

7、write complete waits :

此类等待事件是由于DBWR 将脏数据写入数据文件,其他进程如果需要修改 buffer cache会引起此等待事件,一般是 I/O 性能问题或者是DBWR 工作负荷过量引起

8、control file parallel write:

频繁的更新控制文件会造成大量此类等待事件,如日志频繁切换,检查点经常发生,nologging 引起频繁的数据文件更改,I/O 系统性能缓慢。

9、log file sync:

此类等待时间是由于 LGWR 进程讲redo log buffer 写入redo log 中发生。如果此类事件频繁发生,可以判断为:commit 次数是否过多、I/O 系统问题、重做日志是否不必要被创建、redo log buffer是否过大

2-1 Time Model Statistics

Time Model Statistics

  • Total time in database user-calls (DB Time): 3886.1s
  • Statistics including the word "background" measure background process time, and so do not contribute to the DB time statistic
  • Ordered by % or DB time desc, Statistic name
Statistic NameTime (s)% of DB Time
DB CPU3,823.0998.38
sql execute elapsed time1,382.6135.58
parse time elapsed698.9817.99
hard parse elapsed time340.298.76
PL/SQL execution elapsed time8.170.21
connection management call elapsed time1.190.03
hard parse (sharing criteria) elapsed time0.560.01
PL/SQL compilation elapsed time0.540.01
failed parse elapsed time0.380.01
sequence load elapsed time0.170.00
repeated bind elapsed time0.020.00
DB time3,886.11
background elapsed time248.93
background cpu time48.61

Time Model Statistics几个特别有用的时间指标:

parse time elapsed、hard parse elapsed time 结合起来看解析是否是主要矛盾,若是则重点是软解析还是硬解析

sequence load elapsed time sequence序列争用是否是问题焦点

PL/SQL compilation elapsed time PL/SQL对象编译的耗时

注意PL/SQL execution elapsed time 纯耗费在PL/SQL解释器上的时间。不包括花在执行和解析其包含SQL上的时间

connection management call elapsed time 建立数据库session连接和断开的耗时

failed parse elapsed time 解析失败,例如由于ORA-4031

hard parse(sharing criteria)elapsed time由于无法共享游标造成的硬解析

hard parse(bind mismatch)elapsed time由于bind type or bind size 不一致造成的硬解析
注意该时间模型中的指标存在包含关系所以Time Model Statistics加起来超过100%再正常不过

1) background elapsed time
2) background cpu time
3) RMAN cpu time (backup/restore)
4) DB time
5) DB CPU
6) connection management call elapsed time
7) sequence load elapsed time
8) sql execute elapsed time
9) parse time elapsed
10) hard parse elapsed time
11) hard parse (sharing criteria) elapsed time
12) hard parse (bind mismatch) elapsed time
13) failed parse elapsed time
14) failed parse (out of shared memory) elapsed time
15) PL/SQL execution elapsed time
16) inbound PL/SQL rpc elapsed time
17) PL/SQL compilation elapsed time
18) Java execution elapsed time
19) repeated bind elapsed time

2-2 Foreground Wait Class

Foreground Wait Class

  • s - second, ms - millisecond - 1000th of a second
  • ordered by wait time desc, waits desc
  • %Timeouts: value of 0 indicates value was < .5%. Value of null is truly 0
  • Captured Time accounts for 102.7% of Total DB time 3,886.11 (s)
  • Total FG Wait Time: 166.02 (s) DB CPU time: 3,823.09 (s)
Wait ClassWaits%Time -outsTotal Wait Time (s)Avg wait (ms)%DB time
DB CPU3,82398.38
Commit10,933010292.61
Concurrency5,47904181.07
Network7,965,50201500.40
User I/O31,5040600.14
Application3390250.04
Other5771110.02
Configuration2100060.00
System I/O120000.00


常见的WAIT_CLASS类型
---------------------------------------
Concurrency
User I/O
System I/O
Administrative
Other
Configuration
Scheduler
Cluster
Application
Queueing
Idle
Network
Commit

Wait Class: 等待事件的类型。

Waits: 该类型所属等待事件在快照时间内的等待次数

%Time Out 等待超时的比率,未超时次数/waits * 100 (%)

Total Wait Time: 该类型所属等待事件总的耗时,单位为秒

Avg Wait(ms) : 该类型所属等待事件的平均单次等待时间,单位为ms ,实际这个指标对commit 和 user i/o 以及system i/o类型有点意义

Other 类型,遇到该类型等待事件的话常见的原因是Oracle Bug或者网络、I/O存在问题,建议提交MOS

Concurrency 类型并行争用类型的等待事件,典型的如 latch: shared pool、latch: library cache、row cache lock、library cache pin/lock

Cluster 类型 为Real Application Cluster RAC环境中的等待事件, 需要注意的是如果启用了RAC option,那么即使你的集群中只启动了一个实例,那么该实例也可能遇到 Cluster类型的等待事件, 例如gc buffer busy

System I/O 主要是后台进程维护数据库所产生的I/O,例如control file parallel write 、log file parallel write、db file parallel write。

User I/O 主要是前台进程做了一些I/O操作,并不是说后台进程不会有这些等待事件。典型的如db file sequential/scattered read、direct path read

Configuration 由于配置引起的等待事件,例如日志切换的log file switch

Application 应用造成的等待事件,例如enq: TM – contention和enq: TX – row lock contention;Oracle认为这是由于应用设计不当造成的等待事件, 但实际这些Application class 等待可能受到 Concurrency、Cluster、System I/O 、User I/O等多种类型等待的影响,例如本来commit只要1ms ,则某一行数据仅被锁定1ms,但由于commit变慢从而释放行锁变慢,引发大量的enq: TX – row lock contention等待事件。

Network : 网络类型的等待事件 例如 SQLNet more data to client 、SQLNet more data to dblink

Idle 空闲等待事件 ,最为常见的是rdbms ipc message

SQLNet message from client 等待SQLNET传来信息

2-3 Foreground Wait Events

Foreground Wait Events

  • s - second, ms - millisecond - 1000th of a second
  • Only events with Total Wait Time (s) >= .001 are shown
  • ordered by wait time desc, waits desc (idle events last)
  • %Timeouts: value of 0 indicates value was < .5%. Value of null is truly 0
EventWaits%Time -outsTotal Wait Time (s)Avg wait (ms)Waits /txn% DB time
log file sync10,933010290.012.61
cursor: pin S3,29902370.000.60
SQL*Net message to client7,835,07601308.500.34
latch: shared pool773010130.000.26
direct path read29,4390400.030.11
library cache: mutex X6810350.000.08
cursor: pin S wait on X7303360.000.07
latch: row cache objects5440240.000.06
SQL*Net more data to client122,9000200.130.05
enq: KO - fast object checkpoint2301480.000.03
db file sequential read1,6080110.000.03
latch free5450010.000.01
direct path sync1500180.000.01
kksfbc child completion41000510.000.01
enq: TX - row lock contention800250.000.01
SQL*Net break/reset to client3060010.000.01
SQL*Net more data from client7,5260000.010.00
local write wait70040.000.00
Disk file operations I/O1770000.000.00
enq: RO - fast object reuse200110.000.00
latch: cache buffers chains530000.000.00
reliable message160010.000.00
undo segment extension2100060.000.00
cursor: mutex S100110.000.00
buffer busy waits240000.000.00
read by other session20030.000.00
direct path write2430000.000.00
db file parallel read10030.000.00
latch: session allocation100000.000.00
latch: In memory undo latch120000.000.00
library cache lock20010.000.00
library cache load lock60000.000.00
latch: enqueue hash chains10010.000.00
SQL*Net message from client7,835,0810261,357338.50
jobq slave wait7,4961003,7635020.01

2-4 Background Wait Events

Background Wait Events

  • ordered by wait time desc, waits desc (idle events last)
  • Only events with Total Wait Time (s) >= .001 are shown
  • %Timeouts: value of 0 indicates value was < .5%. Value of null is truly 0
EventWaits%Time -outsTotal Wait Time (s)Avg wait (ms)Waits /txn% bg time
log file parallel write11,570010490.0141.67
db file async I/O submit2,497075300.0030.27
control file parallel write1,576017110.006.77
os thread startup13908600.003.35
db file sequential read1750020.000.13
latch: shared pool1700160.000.11
control file sequential read4,1680000.000.06
direct path sync1001040.000.04
log file sync200280.000.02
ADR block file read160020.000.01
ADR block file write50030.000.01
reliable message230000.000.00
asynch descriptor resize245100000.000.00
Disk file operations I/O660000.000.00
LGWR wait for redo copy320000.000.00
direct path write230000.000.00
rdbms ipc message30,2976261,07120160.03
DIAG idle wait7,1921007,21410030.01
smon timer15733,7552503340.00
shared server idle wait1211003,631300100.00
Streams AQ: qmn coordinator idle wait266483,613135830.00
Streams AQ: qmn slave idle wait12903,613280080.00
pmon timer1,2011003,60930050.00
Space Manager: slave idle wait7221003,60849970.00
dispatcher timer601003,601600120.00
SQL*Net message from client5320010.00
class slave wait190000.00

2-5 Operating System Statistics

Operating System Statistics

  • *TIME statistic values are diffed. All others display actual values. End Value is displayed if different
  • ordered by statistic type (CPU Use, Virtual Memory, Hardware Config), Name
StatisticValueEnd Value
BUSY_TIME389,214
IDLE_TIME5,201,491
IOWAIT_TIME11,255
NICE_TIME0
SYS_TIME155,118
USER_TIME227,910
LOAD01
RSRC_MGR_CPU_WAIT_TIME0
VM_IN_BYTES0
VM_OUT_BYTES0
PHYSICAL_MEMORY_BYTES33,805,135,872
NUM_CPUS16
NUM_CPU_CORES16
NUM_CPU_SOCKETS4
GLOBAL_RECEIVE_SIZE_MAX4,194,304
GLOBAL_SEND_SIZE_MAX1,048,576
TCP_RECEIVE_SIZE_DEFAULT87,380
TCP_RECEIVE_SIZE_MAX4,194,304
TCP_RECEIVE_SIZE_MIN4,096
TCP_SEND_SIZE_DEFAULT16,384
TCP_SEND_SIZE_MAX4,194,304
TCP_SEND_SIZE_MIN4,096


Operating System Statistics 操作系统统计信息, TIME相关的指标单位均为百分之一秒

NUM_CPU_SOCKETS:物理CPU的数目

NUM_CPU_CORES:CPU的核数
NUM_CPUS:逻辑CPU的数目
SYS_TIME:在内核态被消耗掉的CPU时间片,单位为百分之一秒
USER_TIME:在用户态被消耗掉的CPU时间片,单位为百分之一秒
BUSY_TIME:Busy_Time=SYS_TIME+USER_TIME 消耗的CPU时间片,单位为百分之一秒
AVG_BUSY_TIME:AVG_BUSY_TIME= BUSY_TIME/NUM_CPUS
IDLE_TIME 空闲的CPU时间片,单位为百分之一秒
OS_CPU_WAIT_TIME:进程等OS调度的时间
IOWAIT_TIME:所有CPU花费在等待I/O完成上的时间 单位为百分之一秒

2-6 Service Statistcs

Service Statistics

  • ordered by DB Time
Service NameDB Time (s)DB CPU (s)Physical Reads (K)Logical Reads (K)
SYS$USERS3,8863,8231,42881,868
SYS$BACKGROUND00063
cufsoa0000
cufsoaXDB0000

Service Name 对应的服务名 (v$services),

SYS$BACKGROUND代表后台进程,

SYS$USERS一般是系统用户登录

DB TIME (s): 本服务名所消耗的DB TIME时间,单位为秒

DB CPU(s): 本服务名所消耗的DB CPU 时间,单位为秒

Physical Reads : 本服务名所消耗的物理读

Logical Reads : 本服务所消耗的逻辑读

2-7 Service Wait Class Stats

Service Wait Class Stats

  • Wait Class info for services in the Service Statistics section.
  • Total Waits and Time Waited displayed for the following wait classes: User I/O, Concurrency, Administrative, Network
  • Time Waited (Wt Time) in seconds
Service NameUser I/O Total WtsUser I/O Wt TimeConcurcy Total WtsConcurcy Wt TimeAdmin Total WtsAdmin Wt TimeNetwork Total WtsNetwork Wt Time
SYS$USERS31504654794100796551215
SYS$BACKGROUND264014880000
cufsoa00000000

User I/O Total Wts : 对应该服务名下用户I/O类等待的总的次数

User I/O Wt Time :对应该服务名下用户I/O累等待的总时间,单位为 1/100秒

Concurcy Total Wts: 对应该服务名下 Concurrency 类型等待的总次数

Concurcy Wt Time :对应该服务名下 Concurrency 类型等待的总时间, 单位为 1/100秒

Admin Total Wts: 对应该服务名下Admin 类等待的总次数

Admin Wt Time: 对应该服务名下Admin类等待的总时间,单位为1/100秒

Network Total Wts : 对应服务名下Network类等待的总次数

Network Wt Time:对应服务名下Network类等待的总事件,单位为1/100秒**

2-8 Host CPU
**

Host CPU

CPUsCoresSocketsLoad Average BeginLoad Average End%User%System%WIO%Idle
161640.480.624.12.80.293.0

Load Average begin/end值代表每个CPU的大致运行队列大小。

2-8 Instance CPU

Instance CPU

%Total CPU%Busy CPU%DB time waiting for CPU (Resource Manager)
6.999.50.0

%Busy CPU,该实例所使用的Cpu占总的被使用CPU的比例 % of busy CPU for Instance

例如共4个逻辑CPU,其中3个被完全使用,3个中的1个完全被该实例使用,则%Total CPU= ¼ =25%,而%Busy CPU= 1/3= 33%
当CPU高时一般看%Busy CPU可以确定CPU到底是否是本实例消耗的,还是主机上其他程序**

**

3 TOP SQL

3-1 SQL ordered by Elapsed Time ,

SQL ordered by Elapsed Time

  • Resources reported for PL/SQL code includes the resources used by all SQL statements called by the code.
  • % Total DB Time is the Elapsed Time of the SQL statement divided into the Total Database Time multiplied by 100
  • %Total - Elapsed Time as a percentage of Total DB time
  • %CPU - CPU Time as a percentage of Elapsed Time
  • %IO - User I/O Time as a percentage of Elapsed Time
  • Captured SQL account for 13.9% of Total DB Time (s): 3,886
  • Captured PL/SQL account for 0.1% of Total DB Time (s): 3,886
Elapsed Time (s)ExecutionsElapsed Time per Exec (s)%Total%CPU%IOSQL IdSQL ModuleSQL Text
192.02916,6820.004.9446.610.007gwxpwru0czqw
27.05590.460.7098.600.004nwgd6fbmbkm0

注意对于PL/SQL,SQL Statistics不仅会体现该PL/SQL的执行情况,还会包括该PL/SQL包含的SQL语句的情况。

对于Top SQL很有必要一探究竟

Elapsed Time (s): 该SQL累计运行所消耗的时间,

Executions : 该SQL在快照时间内总计运行的次数 ;注意对于在快照时间内还没有执行完的SQL不计为一次,所以如果看到executions=0而又是TOP SQL,则很有可能是因为该SQL运行较旧还没执行完,需要特别关注一下。

Elapsed Time per Exec (s):平均每次执行该SQL耗费的时间,对于OLTP类型的SELECT/INSERT/UPDATE/DELETE而言平均单次执行时间应当非常短,
如0.1秒 或者更短才能满足其业务需求,如果这类轻微的OLTP操作单次也要几秒钟的话,是无法满足对外业务的需求的;如果这些操作也变得很慢,则会出现大量事务阻塞,系统负载升高,DB TIME急剧上升的现象。对于OLTP数据库而言 如果执行计划稳定,那么这些OLTP操作的性能应当是稳定的,但是一旦某个因素 发生变化,例如存储的明显变慢、内存换页的大量出现时则上述的这些transaction操作很可能成数倍到几十倍的变慢,这将让此事务系统短期内不可用。

%Total 该SQL所消耗的时间占总的DB Time的百分比, 即 (SQL Elapsed Time / Total DB TIME)

% CPU 该SQL 所消耗的CPU时间占该SQL消耗的时间里的比例,

%IO 该SQL 所消耗的I/O时间占该SQL消耗的时间里的比例,该指标说明了该语句是否是I/O敏感的

SQL Id : 通过计算SQL 文本获得的SQL_ID ,不同的SQL文本必然有不同的SQL_ID, 对于10g~11g而言 只要SQL文本不变那么在数据库之间 该SQL 对应的SQL_ID应当不不变的, 12c中修改了SQL_ID的计算方法

3-2 SQL ordered by CPU Time

SQL ordered by CPU Time

  • Resources reported for PL/SQL code includes the resources used by all SQL statements called by the code.
  • %Total - CPU Time as a percentage of Total DB CPU
  • %CPU - CPU Time as a percentage of Elapsed Time
  • %IO - User I/O Time as a percentage of Elapsed Time
  • Captured SQL account for 10.1% of Total CPU Time (s): 3,823
  • Captured PL/SQL account for 0.0% of Total CPU Time (s): 3,823
CPU Time (s)ExecutionsCPU per Exec (s)%TotalElapsed Time (s)%CPU%IOSQL IdSQL ModuleSQL Text
89.51916,6820.002.34192.0246.610.007gwxpwru0czqw
26.67590.450.7027.0598.600.004nwgd6fbmbkm0

CPU TIME : 该SQL在快照时间内累计执行所消耗的CPU时间片,单位为s

Executions : 该SQL在快照时间内累计执行的次数

CPU per Exec (s) :该SQL 平均单次执行所消耗的CPU时间,

%Total : 该SQL累计消耗的CPU时间占该时段总的DB CPU的比例,

% CPU 该SQL 所消耗的CPU时间占该SQL消耗的时间里的比例,该指标说明了该语句是否是CPU敏感的

%IO 该SQL 所消耗的I/O时间占该SQL消耗的时间里的比例, 该指标说明了该语句是否是I/O敏感的

3-3 Buffer Gets SQL ordered by Gets

SQL ordered by Reads

  • %Total - Physical Reads as a percentage of Total Disk Reads
  • %CPU - CPU Time as a percentage of Elapsed Time
  • %IO - User I/O Time as a percentage of Elapsed Time
  • Total Disk Reads: 1,427,765
  • Captured SQL account for 0.0% of Total
Physical ReadsExecutionsReads per Exec%TotalElapsed Time (s)%CPU%IOSQL IdSQL ModuleSQL Text
03,2180.000.000.7837.010.00074w4jr8a9fu8
033,1800.000.007.5563.610.0009tx5h4ngu7va

注意 buffer gets 逻辑读是消耗CPU TIME的重要源泉, 但并不是说消耗CPU TIME的只有buffer gets。

大多数情况下 SQL order by CPU TIME和SQL order by buffers gets 2个部分的TOP SQL 及其排列顺序都是一样的,此种情况说明消耗最多buffer gets的 就是消耗最多CPU 的SQL ,如果我们希望降低系统的CPU使用率,那么只需要调优SQL 降低buffer gets 即可。

但也并不是100%的情况都是如此,CPU TIME的消耗者还包括函数运算、PL/SQL 控制、Latch /Mutex 的Spin等等, 所以SQL order by CPU TIME 和 SQL order by buffers gets 2个部分的TOP SQL 完全不一样也是有可能的,

Buffer Gets : 该SQL在快照时间内累计运行所消耗的buffer gets,包括了consistent read 和 current read

Executions : 该SQL在快照时间内累计执行的次数

Gets per Exec : 该SQL平均单次的buffer gets , 对于事务型transaction操作而言 一般该单次buffer gets小于2000

% Total 该SQL累计运行所消耗的buffer gets占总的db buffer gets的比率,

3-4 Physical Reads SQL ordered by Reads

SQL ordered by Physical Reads (UnOptimized)

  • UnOptimized Read Reqs = Physical Read Reqts - Optimized Read Reqs
  • %Opt - Optimized Reads as percentage of SQL Read Requests
  • %Total - UnOptimized Read Reqs as a percentage of Total UnOptimized Read Reqs
  • Total Physical Read Requests: 31,234
  • Captured SQL account for 0.0% of Total
  • Total UnOptimized Read Requests: 31,234
  • Captured SQL account for 0.0% of Total
  • Total Optimized Read Requests: 1
  • Captured SQL account for 0.0% of Total
UnOptimized Read ReqsPhysical Read ReqsExecutionsUnOptimized Reqs per Exec%Opt%TotalSQL IdSQL ModuleSQL Text
1212112.000.000.04gjm43un5cy843
003,2180.000.00074w4jr8a9fu8

Physical reads : 该SQL累计运行所消耗的物理读

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信dbaup66,谢谢!
AiDBA后续精彩内容已被站长无情隐藏,请输入验证码解锁本文!
验证码:
获取验证码: 请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“AiDBA”或者“dbaup6”或者微信扫描右侧二维码都可以关注本站微信公众号。

标签:

Avatar photo

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复