查看: 4844|回复: 9

Wait_time + DB CPU << DB time 疑问

[复制链接]
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
跳转到指定楼层
1#
发表于 2011-5-12 12:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
环境: AIX 5300-11  30408704M memory
         oracle10.2.0.4 single instance

最近我在监控性能发现DB time的时间远大于Wait_time+DB CPU, 查阅了很多文章都没结果,贴出来麻烦大家帮我分析一下。

1. 摘录一部分AWR报告


WORKLOAD REPOSITORY report for

DB Name         DB Id    Instance     Inst Num Release     RAC Host
------------ ----------- ------------ -------- ----------- --- ------------
PROD           741258667 prod                1 10.2.0.4.0  NO  db1
              Snap Id      Snap Time      Sessions Curs/Sess
            --------- ------------------- -------- ---------
Begin Snap:     33350 11-May-11 21:00:37        54      12.7
  End Snap:     33351 11-May-11 22:00:02        52      13.0
   Elapsed:              59.40 (mins
   DB Time:              491.09 (mins)

Cache Sizes
~~~~~~~~~~~                       Begin        End
                             ---------- ----------
               Buffer Cache:     1,312M     1,824M  Std Block Size:         8K
           Shared Pool Size:     2,048M     1,536M      Log Buffer:    14,340K

Load Profile
~~~~~~~~~~~~                            Per Second       Per Transaction
                                   ---------------       ---------------
                  Redo size:            300,289.48             32,217.57
              Logical reads:             76,388.09              8,195.55
              Block changes:              2,117.34                227.17
             Physical reads:                299.05                 32.08
            Physical writes:                 59.13                  6.34
                 User calls:              2,673.46                286.83
                     Parses:                 69.52                  7.46
                Hard parses:                  3.56                  0.38
                      Sorts:                 67.15                  7.20
                     Logons:                  0.27                  0.03
                   Executes:                182.25                 19.55
               Transactions:                  9.32

  % Blocks changed per Read:    2.77    Recursive Call %:    25.42
Rollback per transaction %:    0.53       Rows per Sort:     8.80

Instance Efficiency Percentages (Target 100%)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            Buffer Nowait %:  100.00       Redo NoWait %:  100.00
            Buffer  Hit   %:   99.61    In-memory Sort %:  100.00
            Library Hit   %:   97.83        Soft Parse %:   94.87
         Execute to Parse %:   61.85         Latch Hit %:   99.99
Parse CPU to Parse Elapsd %:   19.84     % Non-Parse CPU:   97.76

Shared Pool Statistics        Begin    End
                              ------  ------
             Memory Usage %:   44.96   24.17
    % SQL with executions>1:   82.40   92.53
  % Memory for SQL w/exec>1:   89.61   84.47

Top 5 Timed Events                                         Avg %Total
~~~~~~~~~~~~~~~~~~                                        wait   Call
Event                                 Waits    Time (s)   (ms)   Time Wait Class
------------------------------ ------------ ----------- ------ ------ ----------
CPU time                                          3,201          10.9
db file scattered read              187,905       1,903     10    6.5   User I/O
latch: shared pool                    2,071         264    128    0.9 Concurrenc
latch: library cache                  2,363         249    106    0.8 Concurrenc
db file sequential read              12,000         220     18    0.7   User I/O
          -------------------------------------------------------------
Time Model Statistics                  DB/Inst: PROD/prod  Snaps: 33350-33351
-> Total time in database user-calls (DB Time): 29465.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 name

Statistic Name                                       Time (s) % of DB Time
------------------------------------------ ------------------ ------------
sql execute elapsed time                             29,915.6        101.5
Java execution elapsed time                          15,483.6         52.5
PL/SQL execution elapsed time                         9,162.4         31.1
DB CPU                                                3,200.7         10.9
parse time elapsed                                      686.4          2.3
hard parse elapsed time                                 502.1          1.7
PL/SQL compilation elapsed time                         108.5           .4
sequence load elapsed time                               16.7           .1
repeated bind elapsed time                                0.9           .0
hard parse (sharing criteria) elapsed time                0.6           .0
connection management call elapsed time                   0.3           .0
failed parse elapsed time                                 0.0           .0
hard parse (bind mismatch) elapsed time                   0.0           .0
DB time                                              29,465.3          N/A
background elapsed time                                 658.2          N/A
background cpu time                                      18.9          N/A
          -------------------------------------------------------------

Wait Class                              DB/Inst:PROD/prod  Snaps: 33350-33351
-> 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

                                                                  Avg
                                       %Time       Total Wait    wait     Waits
Wait Class                      Waits  -outs         Time (s)    (ms)      /txn
-------------------- ---------------- ------ ---------------- ------- ---------
User I/O                      208,244     .0            2,133      10       6.3
Concurrency                     7,698   31.2              551      72       0.2
System I/O                     43,643     .0              344       8       1.3
Network                    10,165,606     .0               11       0     306.0
Application                       399     .0                9      23       0.0
Commit                          1,066     .0                7       7       0.0
Other                           1,419    2.3                6       4       0.0
Configuration                      41     .0                3      82       0.0
          -------------------------------------------------------------

Wait Events                            DB/Inst: PROD/prod  Snaps: 33350-33351
-> 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
                                             %Time  Total Wait    wait     Waits
Event                                 Waits  -outs    Time (s)    (ms)      /txn
---------------------------- -------------- ------ ----------- ------- ---------
db file scattered read              187,905     .0       1,903      10       5.7
latch: shared pool                    2,071     .0         264     128       0.1
latch: library cache                  2,363     .0         249     106       0.1
db file sequential read              12,000     .0         220      18       0.4
log file parallel write              36,240     .0         178       5       1.1
db file parallel write                3,410     .0         159      47       0.1
cursor: pin S wait on X               2,402  100.0          24      10       0.1
enq: UL - contention                    122     .0           8      63       0.0
log file sync                         1,066     .0           7       7       0.0
os thread startup                       148     .0           7      46       0.0
SQL*Net message to client         9,515,904     .0           6       0     286.5
control file parallel write           1,237     .0           5       4       0.0
SQL*Net more data to client         648,854     .0           5       0      19.5
read by other session                    84     .0           4      48       0.0
direct path write                     2,756     .0           4       1       0.1
enq: SQ - contention                     22     .0           3     134       0.0
library cache load lock                  20     .0           3     142       0.0
direct path read                      5,494     .0           2       0       0.2
latch: redo allocation                   72     .0           2      24       0.0
enq: JS - queue lock                     46     .0           2      36       0.0
SQL*Net break/reset to clien            246     .0           1       6       0.0
latch: row cache objects                 41     .0           1      33       0.0
control file sequential read          2,740     .0           1       0       0.1
latch: cache buffers chains             133     .0           1       6       0.0
latch free                               34     .0           1      23       0.0
enq: TX - contention                      9     .0           1      76       0.0
latch: object queue header o             19     .0           0      23       0.0
LGWR wait for redo copy                 933    2.8           0       0       0.0
enq: TX - index contention                4     .0           0      94       0.0
log file switch completion                8     .0           0      41       0.0
buffer busy waits                       467     .0           0       1       0.0
kksfbc child completion                   2  100.0           0      49       0.0
latch: redo writing                       2     .0           0      48       0.0
latch: cache buffers lru cha              9     .0           0       8       0.0
rdbms ipc reply                         284     .0           0       0       0.0
log file single write                     8     .0           0       3       0.0
latch: In memory undo latch              45     .0           0       0       0.0
latch: session allocation                 2     .0           0       9       0.0
latch: enqueue hash chains                4     .0           0       5       0.0
latch: library cache lock                 1     .0           0      12       0.0
enq: TX - row lock contentio             31     .0           0       0       0.0
enq: HW - contention                      9     .0           0       1       0.0
log file sequential read                  8     .0           0       1       0.0
SQL*Net more data from clien            805     .0           0       0       0.0
direct path write temp                    5     .0           0       0       0.0
SQL*Net more data from dblin              6     .0           0       0       0.0
SQL*Net message to dblink                36     .0           0       0       0.0
enq: FB - contention                      1     .0           0       0       0.0
SQL*Net more data to dblink               1     .0           0       0       0.0
buffer deadlock                           4  100.0           0       0       0.0
cursor: mutex S                           3     .0           0       0       0.0
SQL*Net message from client       9,515,902     .0      48,075       5     286.5
Streams AQ: waiting for time            369   70.7      26,143   70849       0.0
jobq slave wait                       5,562   85.2      15,209    2734       0.2
Streams AQ: qmn coordinator           1,341   39.6       3,481    2596       0.0
EMON idle wait                          713  100.0       3,478    4879       0.0
wait for unread message on b          3,655   97.2       3,478     952       0.1
Streams AQ: waiting for mess            712  100.0       3,470    4874       0.0
virtual circuit status                  119  100.0       3,458   29057       0.0
Streams AQ: qmn slave idle w            714     .0       3,454    4838       0.0
Wait Events                            DB/Inst: PROD/prod  Snaps: 33350-33351
-> 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
                                             %Time  Total Wait    wait     Waits
Event                                 Waits  -outs    Time (s)    (ms)      /txn
---------------------------- -------------- ------ ----------- ------- ---------
SGA: MMAN sleep for componen             40   82.5           0       9       0.0
single-task message                       1     .0           0     301       0.0
SQL*Net message from dblink              36     .0           0       1       0.0
class slave wait                          3     .0           0       0       0.0
          -------------------------------------------------------------

Background Wait Events                 DB/Inst: PROD/prod  Snaps: 33350-33351
-> ordered by wait time desc, waits desc (idle events last)

                                                                   Avg
                                             %Time  Total Wait    wait     Waits
Event                                 Waits  -outs    Time (s)    (ms)      /txn
---------------------------- -------------- ------ ----------- ------- ---------
log file parallel write              36,247     .0         178       5       1.1
db file parallel write                3,410     .0         159      47       0.1
latch: shared pool                      181     .0          35     195       0.0
latch: library cache                    175     .0          32     184       0.0
db file sequential read               2,390     .0          15       6       0.1
os thread startup                       148     .0           7      46       0.0
control file parallel write           1,238     .0           5       4       0.0
events in waitclass Other             1,350    1.9           2       2       0.0
latch: row cache objects                  7     .0           1      90       0.0
control file sequential read          1,443     .0           1       0       0.0
db file scattered read                   25     .0           1      23       0.0
latch: cache buffers chains              81     .0           1       7       0.0
direct path write                        70     .0           0       3       0.0
latch: redo writing                       2     .0           0      48       0.0
direct path read                         70     .0           0       1       0.0
log file single write                     8     .0           0       3       0.0
log file sequential read                  8     .0           0       1       0.0
buffer busy waits                         2     .0           0       0       0.0
rdbms ipc message                    45,069   26.0      30,741     682       1.4
Streams AQ: waiting for time            369   70.7      26,143   70849       0.0
pmon timer                            1,241  100.0       3,483    2807       0.0
Streams AQ: qmn coordinator           1,341   39.6       3,481    2596       0.0
EMON idle wait                          713  100.0       3,478    4879       0.0
smon timer                              198     .0       3,458   17463       0.0
Streams AQ: qmn slave idle w            714     .0       3,454    4838       0.0
SGA: MMAN sleep for componen             40   82.5           0       9       0.0
          -------------------------------------------------------------

Operating System Statistics             DB/Inst: PROD/prod  Snaps: 33350-33351

Statistic                                       Total
-------------------------------- --------------------
NUM_LCPUS                                           0
NUM_VCPUS                                           0
AVG_BUSY_TIME                                  80,897
AVG_IDLE_TIME                                 275,913
AVG_IOWAIT_TIME                                66,666
AVG_SYS_TIME                                   22,040
AVG_USER_TIME                                  58,739
BUSY_TIME                                     485,943
IDLE_TIME                                   1,656,091
IOWAIT_TIME                                   400,567
SYS_TIME                                      132,880
USER_TIME                                     353,063
LOAD                                                0
OS_CPU_WAIT_TIME                              578,200
RSRC_MGR_CPU_WAIT_TIME                              0
PHYSICAL_MEMORY_BYTES                  31,138,447,360
NUM_CPUS                                            6
NUM_CPU_CORES                                       3


2. 所有的事件百分比加起来还不到20%,加上其他的也不会超过30%。应该说DB很闲,但是为什么DB Time是491.09mis呢?
3. DB time = 491.09min = 29465.4s
    DB cpu  = 3,200.7s
    Wait_time 通过以下SQL来计算出来是: 3063s, DB time是不算Idle等待和background的
   
    DB cpu(3200.7)+ wait_time(3063) = 6263.7s, 此数字远远小于DB time(29465.4s), 那剩下的时间干什么去了呢??
   很不明白,难道Oracle有Bug,去support看了一下,只是说等待direct path....相关的等待会有问题,但我这儿没有这样的事件。
   我又看到一篇文件说:Wait_time + DB CPU << DB time 可能cpu非常繁忙,有cpu queue情况,但是我这里CPU应该是很闲的,而且有6个CPU。


select snap_id,begin_interval_time,end_interval_time,
       round(sum(time_waited)/1000000) time_waited
  from (
         select a.dbid
              , a.instance_number
              , a.snap_id
              , a.event_name
              , a.wait_class
              , s.startup_time
              , s.begin_interval_time
              , s.end_interval_time
              , (case when s.begin_interval_time = s.startup_time then a.time_waited_micro
                         else a.time_waited_micro - lag( a.time_waited_micro, 1 )
                                      over (partition by a.event_id, a.dbid, a.instance_number, s.startup_time
                                                                  order by a.snap_id) end )  time_waited

        from dba_hist_system_event a,
             dba_hist_snapshot s
       where a.dbid=s.dbid
         and a.instance_number=s.instance_number
         and a.snap_id=s.snap_id
         and wait_class<>'Idle'
         and a.snap_id in (33350,33351)
      )
where time_waited is not null
group by snap_id,begin_interval_time,end_interval_time


[ 本帖最后由 Osric 于 2011-5-12 13:30 编辑 ]
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
2#
 楼主| 发表于 2011-5-12 13:33 | 只看该作者
有知道的吗?谁帮我解惑一下。

使用道具 举报

回复
fuger2 该用户已被删除
3#
发表于 2011-5-12 15:20 | 只看该作者
有几颗cpu?

使用道具 举报

回复
论坛徽章:
2
2011新春纪念徽章
日期:2011-02-18 11:43:34蜘蛛蛋
日期:2011-07-17 23:51:25
4#
发表于 2011-5-12 19:29 | 只看该作者
有种说法:
DB time = Wait_time+DB CPU+Wait for CPU
DB time的时间远大于Wait_time+DB CPU可能暗示cpu存在比较严重的争用

[ 本帖最后由 hnfrank 于 2011-5-12 19:31 编辑 ]

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
5#
 楼主| 发表于 2011-5-13 13:18 | 只看该作者
原帖由 fuger2 于 2011-5-12 15:20 发表
有几颗cpu?


6

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
6#
 楼主| 发表于 2011-5-13 13:19 | 只看该作者
原帖由 hnfrank 于 2011-5-12 19:29 发表
有种说法:
DB time = Wait_time+DB CPU+Wait for CPU
DB time的时间远大于Wait_time+DB CPU可能暗示cpu存在比较严重的争用


但是在我的报告中,cpu使用并不高呀。

使用道具 举报

回复
论坛徽章:
73
2010新春纪念徽章
日期:2010-03-01 11:06:132011新春纪念徽章
日期:2011-02-18 11:43:332012新春纪念徽章
日期:2012-01-04 11:55:422013年新春福章
日期:2013-02-25 14:51:242014年新春福章
日期:2014-02-18 16:44:08马上有车
日期:2015-01-19 09:45:33最佳人气徽章
日期:2012-03-13 17:39:18ITPUB季度 技术新星
日期:2012-11-27 10:16:10问答徽章
日期:2013-10-23 15:13:22林肯
日期:2013-11-02 08:34:46
7#
发表于 2011-5-13 13:50 | 只看该作者
Wait_time 的计算公式是哪里看到的?

使用道具 举报

回复
论坛徽章:
2
授权会员
日期:2005-10-30 17:05:33ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
8#
 楼主| 发表于 2011-5-13 14:10 | 只看该作者
原帖由 XQKA 于 2011-5-13 13:50 发表
Wait_time 的计算公式是哪里看到的?


AWR报告就是这样计算的

SELECT EVENT, WAITS, TIME, PCTWTT, WAIT_CLASS
             FROM (SELECT E.EVENT_NAME                           EVENT,
                          E.TOTAL_WAITS - NVL(B.TOTAL_WAITS,0)   WAITS,
                          (E.TIME_WAITED_MICRO -
                           NVL(B.TIME_WAITED_MICRO,0)) / 1000000 TIME,
                          100 * (E.TIME_WAITED_MICRO -
                                        NVL(B.TIME_WAITED_MICRO,0)) /
                                 RPT_STATS(STAT_DBTIME)          PCTWTT,
                          E.WAIT_CLASS                           WAIT_CLASS
                    FROM DBA_HIST_SYSTEM_EVENT B,
                         DBA_HIST_SYSTEM_EVENT E
                    WHERE B.SNAP_ID(+)          = L_BID
                      AND E.SNAP_ID             = L_EID
                      AND B.DBID(+)             = L_DBID
                      AND E.DBID                = L_DBID
                      AND B.INSTANCE_NUMBER(+)  = L_INST_NUM
                      AND E.INSTANCE_NUMBER     = L_INST_NUM
                      AND B.EVENT_ID(+)         = E.EVENT_ID
                      AND E.TOTAL_WAITS         > NVL(B.TOTAL_WAITS,0)
                      AND E.WAIT_CLASS         != 'Idle'

使用道具 举报

回复
论坛徽章:
73
2010新春纪念徽章
日期:2010-03-01 11:06:132011新春纪念徽章
日期:2011-02-18 11:43:332012新春纪念徽章
日期:2012-01-04 11:55:422013年新春福章
日期:2013-02-25 14:51:242014年新春福章
日期:2014-02-18 16:44:08马上有车
日期:2015-01-19 09:45:33最佳人气徽章
日期:2012-03-13 17:39:18ITPUB季度 技术新星
日期:2012-11-27 10:16:10问答徽章
日期:2013-10-23 15:13:22林肯
日期:2013-11-02 08:34:46
9#
发表于 2011-5-13 14:39 | 只看该作者

good

Parse CPU to Parse Elapsd %:   19.84     太低
SGA 小了点
其他的也没发现什么问题。你的系统又不繁忙,那几个time容易失真.

使用道具 举报

回复
论坛徽章:
116
ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24马上有对象
日期:2014-02-19 11:55:14马上加薪
日期:2014-02-19 11:55:14沸羊羊
日期:2015-03-04 14:43:432015年新春福章
日期:2015-03-06 11:57:31喜羊羊
日期:2015-03-25 15:04:022010数据库技术大会纪念徽章
日期:2015-04-23 10:33:192011数据库大会纪念章
日期:2015-04-23 10:33:192012数据库大会纪念章
日期:2015-04-23 10:33:192013数据库大会纪念章
日期:2015-04-23 10:33:19
10#
发表于 2011-5-13 17:18 | 只看该作者
还要算上 sql execute elapsed time

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表