本文共 5951 字,大约阅读时间需要 19 分钟。
Oracle数据库从10g开始,启用以时间模型统计为主,命中率为辅等性能度量指标。基于时间模型统计,主要是基于操作类型测量在数据库中花费的时间的统计信息。最重要的时间模型统计是数据库时间,或DB时间。数据库时间表示在数据库调用中所花费的总时间,是实例工作负载量的总指示器。本文描述时间模型统计相关知识点。
下图为 DB Time in Overall User Response Time
即所有花费在数据库层面调用时间的总和,包括所有会话(前台进程)以及非空闲等待,CPU时间等
如上图所示,从客户端Browser请求到客户端Browser响应,经历了很多个中间环节,DB Time仅仅是其中的一部分2、User Response Time(用户响应时间)
下图为 DB Time in User Transaction
在上图各个部分的操作中:
用户向数据库发出请求,使用向下箭头所示。用于处理请求的数据库所花费的CPU时间和等待数据库等待的时间被认为是DB时间,由阴影区域表示一旦请求完成,结果将返回给用户,如上箭头所示。 上下箭头之间的空间代表处理请求的总用户响应时间,它包含除DB时间以外的其他组件。Time Model Statistics DB/Inst: ORA11G/ora11g Snaps: 551-553-> Total time in database user-calls (DB Time): 1264.3s-> 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 nameStatistic Name Time (s) % of DB Time------------------------------------------ ------------------ ------------sql execute elapsed time 1,188.0 94.0DB CPU 274.3 21.7parse time elapsed 10.1 .8connection management call elapsed time 6.5 .5PL/SQL execution elapsed time 3.2 .3hard parse elapsed time 2.9 .2PL/SQL compilation elapsed time 0.5 .0hard parse (sharing criteria) elapsed time 0.4 .0hard parse (bind mismatch) elapsed time 0.1 .0repeated bind elapsed time 0.0 .0failed parse elapsed time 0.0 .0sequence load elapsed time 0.0 .0DB time 1,264.3background elapsed time 857.8background cpu time 25.4
在Oracle数据库中,最重要的时间模型统计是DB Time和DB CPU。这两个统计数据直接显示数据库的工作量和描述整个数据库的响应时间。
SELECT ss.username, se.SID, VALUE / 100 cpu_usage_secondsFROM v$session ss, v$sesstat se, v$statname snWHERE se.STATISTIC# = sn.STATISTIC# AND NAME LIKE '%CPU used by this session%' AND se.SID = ss.SID AND ss.status = 'ACTIVE' AND ss.username IS NOT NULLORDER BY VALUE DESC;USERNAME SID CPU_USAGE_SECONDS--------------- ---------- -----------------SYSMAN 156 77.69DBSNMP 66 25.86SYS 131 .06DBSNMP 66 0SYS 131 0
COLUMN wait_class FORMAT a20COLUMN name FORMAT a30COLUMN time_secs FORMAT 999,999,999,999.99COLUMN pct FORMAT 99.99SELECT wait_class, NAME, ROUND (time_secs, 2) time_secs, ROUND (time_secs * 100 / SUM (time_secs) OVER (), 2) pctFROM (SELECT n.wait_class, e.event NAME, e.time_waited / 100 time_secs FROM v$system_event e, v$event_name n WHERE n.NAME = e.event AND n.wait_class <> 'Idle' AND time_waited > 0 UNION SELECT 'CPU', 'server CPU', SUM (VALUE / 1000000) time_secs FROM v$sys_time_model WHERE stat_name IN ('background cpu time', 'DB CPU'))ORDER BY time_secs DESC;WAIT_CLASS NAME TIME_SECS PCT-------------------- ------------------------------ ------------------- ------System I/O control file parallel write 3,671.39 33.70System I/O db file async I/O submit 1,832.96 16.82CPU server CPU 1,824.20 16.74System I/O log file parallel write 1,396.98 12.82Commit log file sync 936.36 8.59User I/O direct path write 570.01 5.23Concurrency os thread startup 138.38 1.27Configuration log file switch (checkpoint in 120.05 1.10 complete)
五、相关视图数据字典
V$SYS_TIME_MODEL
V$SESS_TIME_MODEL DBA_HIST_SYS_TIME_MODEL