SlideShare une entreprise Scribd logo
1  sur  43
Télécharger pour lire hors ligne
ASH – Active Session History

Feel the Power

               Kyle Hailey
          http://perfvision.com




                                  #.1
Why should you care?

Because ASH can Change your life …

 10g immediately Accessible
    Geeks: Via scripts in SQL
    Managers : Graphical OEM


 Stuck on Oracle 7,8,9 ?
  … my apologies because 10g rocks, but …
  no worries, the data is accessible for you too via scripts

       http://perfvision.com/sash.php


                       Copyright 2006 Kyle Hailey              #.2
Revolution and an Evolution

Oracle 6 … ie the dark ages … there
 was once the Cache Buffer Hit Ratio

Oracle 7 … turned the lights on … Wait
 Events … hallelujah I can see the light

Oracle 10g … ASH has landed

(like the wheels on the suitcases)
                              Copyright 2006 Kyle Hailey   #.3
Sampling
New Paradigm
  Clear Vision of the future
     Use new sampling technology
     Lets go of the need to know 100%
     Statistical approximation

  Cheaper
  Richer Multidimensional Data
  Identifies
     SQL
     Sessions
     Objects
     Machine
     User




                        Copyright 2006 Kyle Hailey   #.4
Identify Players before ASH
    Sessions v$sesstat, v$session_event
     # sessions x (# wait events + statistics)
      Example (150 x (800+200) = 150,000 )

    SQL
      v$sql
          Could be 10000s
          Takes out latches that compete with other sql executions
    Objects
                                                   Also files v$filestat
      V$segstat    9i+
          Could be 1000s of objects

    Expensive !
                          Copyright 2006 Kyle Hailey                       #.5
ASH
Intelligence for the new Millennium
  Intelligently Collects Data
     Samples once a second
     Collects active sessions only
     Collects Session/SQL/Wait
     More activity, more data collected
     Less activity, less data collected

  Those old methods collected everything
     Obfuscated the problem, too many statistics too late
     Costly
     Too Granular – once an hour ?! Give me a break

  Collects fine grain multidimensional data



                          Copyright 2006 Kyle Hailey         #.6
ASH Fields
SQL> v$active_session_history
 Name                                         Null?    Type
SAMPLE_ID                                                     NUMBER
SAMPLE_TIME                                                   TIMESTAMP(3)
SESSION_ID                                                    NUMBER
SESSION_SERIAL#                                               NUMBER
USER_ID                                                       NUMBER
SQL_ID                                                        VARCHAR2(13)
SQL_CHILD_NUMBER                                              NUMBER
SQL_PLAN_HASH_VALUE                                           NUMBER
SQL_OPCODE                                                    NUMBER
SERVICE_HASH                                                  NUMBER
SESSION_TYPE                                                  VARCHAR2(10)
SESSION_STATE                                                 VARCHAR2(7)
QC_SESSION_ID                                                 NUMBER
QC_INSTANCE_ID                                                NUMBER
EVENT                                                         VARCHAR2(64)
EVENT_ID                                                      NUMBER
EVENT#                                                        NUMBER
SEQ#                                                          NUMBER
P1                                                            NUMBER
P2                                                            NUMBER
P3                                                            NUMBER
WAIT_TIME                                                     NUMBER
TIME_WAITED                                                   NUMBER
CURRENT_OBJ#                                                  NUMBER
CURRENT_FILE#                                                 NUMBER
CURRENT_BLOCK#                                                NUMBER
PROGRAM                                                       VARCHAR2(48)
MODULE                                                        VARCHAR2(48)
ACTION                                                        VARCHAR2(32)
CLIENT_ID                 Copyright 2006 Kyle Hailey          VARCHAR2(64    #.7
v$active_session_history
   When        SAMPLE_ID
               SAMPLE_TIME
                                                        NUMBER
                                                        TIMESTAMP(3)
               SESSION_ID                               NUMBER
               SESSION_SERIAL#                          NUMBER
   Session     USER_ID
               SERVICE_HASH
                                                        NUMBER
                                                        NUMBER
               SESSION_TYPE                             VARCHAR2(10)
               PROGRAM                                  VARCHAR2(64)
               MODULE                                   VARCHAR2(48)
               ACTION                                   VARCHAR2(32)
               CLIENT_ID                                VARCHAR2(64)
    State     SESSION_STATE                             VARCHAR2(7)
              WAIT_TIME                                 NUMBER
              EVENT                                     VARCHAR2(64)
              EVENT_ID                                  NUMBER
              EVENT#                                    NUMBER
              SEQ#                                      NUMBER
   Wait       P1                                        NUMBER
              P2                                        NUMBER
              P3                                        NUMBER
              WAIT_TIME                                 NUMBER
              TIME_WAITED                               NUMBER
              CURRENT_OBJ#                              NUMBER
              CURRENT_FILE#                             NUMBER
              CURRENT_BLOCK#                            NUMBER0
              SQL_ID                                    VARCHAR2(13)
              SQL_CHILD_NUMBER                          NUMBER
   SQL        SQL_PLAN_HASH_VALUE
              SQL_OPCODE
                                                        NUMBER
                                                        NUMBER
              QC_SESSION_ID                             NUMBER
              QC_INSTANCE_ID                            NUMBER
   Duration   TIME_WAITED           Copyright 2006 Kyle Hailey
                                                        NUMBER         #.8
Primary Fields of ASH
  Activity : Who, What, When, How



When    SAMPLE_TIME                                   Time

Who      SESSION_ID                                   Session

         SESSION_STATE                                State
How
         EVENT                                        Wait
What     SQL_ID                                       SQL



                         Copyright 2006 Kyle Hailey             #.9
Amazing things YOU can do
Top SQL        Top Consumers                         Top Resources
 SQL ID        Session                             • CPU
 Plan     X    User
                Object                          X   • Waits
 Child#
                Module.Action
                                                        • Event (800*)
                Program                             • I/O
                Service                                • File
                Client                                 • Block
                Wait                                • Time

     And Aggregated over any time Period

                                        (32 columns in ASH 10.1)
                    Copyright 2006 Kyle Hailey                     #.10
Multi-dimensional
                SQL
            F1qcyh20550cf
Package
Procedure   fj6gjgsshtxyx
Plan        0cjsxw5ndqdbc
Child #
            8t8as9usk11qw

            dr1rkrznhh95b
                                                                                    W
                                                                               St       a
            10dkqv3kr8xa5
                                                             C                   at its
            38zhkf4jdyff4                                  En PU                   ist
            298wmz1kxjs1m
                                                         S q:
                                                      db QL TX
                                                                                       ics
                                                    db fil *Ne –
                            25 34 36 38 45 63 65 87   fil e s t b row
            Sessions                                     e ca r e
                                                          se tt a loc
                                                            qu ere k/r k
                                                              en d es co
            Program          Sqlplus      Toad                  t i a re e t n t e
                                                                     l r ad to nt
                                                                        ea    c l io
                                                                           d     ie n
                                                                                   nt
            User            Sys         Scott      System
                                                                                           Ap
                                                                                              pl
            Service                                                                              ic
                                  GL              OE                                    IO          at
                                                                                                       io
                                                                                                          n

                                                                                                   #.11
Groupings – Top Consumer
SESSION_ID
SESSION_SERIAL#   (identify SID reuse)
SESSION_TYPE      (FOREGROUND,BACKGROUND)
USER_ID           (SYS, SYSTEM, SCOTT etc)
SERVICE_HASH      (OE,GL,HR)
MODULE.ACTION     (PLSQL tagging)
CLIENT_ID         (identifying users in session pool)
PROGRAM           (SQL, JDBC, Forms etc)
SQL_ID
QC_SESSION_ID     (Query Coordinator)
QC_INSTANCE_ID    (RAC)
EVENT + P1, P2, P3
CURRENT_OBJ#
CURRENT_FILE#
CURRENT_BLOCK#
                     Copyright 2006 Kyle Hailey         #.12
Top CPU Session
Top CPU consuming Session in last 5 minutes
 Select
 Select
            session_id,              Who is the rogue session ?
             session_id,
            count(*)
             count(*)
 from
  from
            v$active_session_history
             v$active_session_history
 where
 where
            session_state= ‘ON CPU‘ and
             session_state= ‘ON CPU‘ and
            SAMPLE_TIME > sysdate – (5/(24*60))
             SAMPLE_TIME > sysdate – (5/(24*60))
 group by
 group by
            session_id
            session_id
 order by
 order by
               count(*) desc;
                count(*) desc;
                      Copyright 2006 Kyle Hailey                  #.13
Results Top CPU Session




     SESSION_ID
     SESSION_ID   COUNT(*)
                  COUNT(*)
     ---------- ----------
     ---------- ----------
            257
            257        299
                       299
            263
            263         62
                        62
            256
            256         32
                        32
            264
            264          9
                         9
            277
            277          3
                         3
            258
            258          1
                         1




                 Copyright 2006 Kyle Hailey   #.14
CPU with Bars



   SESSION_ID
    SESSION_ID COUNT(*)
                 COUNT(*)         % Bar
                                   % Bar
   ---------- ---------- ---------- ------------
    ---------- ---------- ---------- ------------
          257
           257       299
                      299        99 |**********|
                                  99 |**********|
          263
           263        62
                       62        21 |**
                                  21 |**       ||
          256
           256        32
                       32        11 |*
                                  11 |*        ||
          264
           264         99         3 |
                                   3 |         ||
          277
           277         33         1 |
                                   1 |         ||
          258
           258         11         0 |
                                   0 |         ||
          280
           280         11         0 |
                                   0 |         ||




   Bar shows 10% increments

                     Copyright 2006 Kyle Hailey     #.15
Top Waiting Session
 Top Waiting Session in last 5 minutes

    Select
     Select
           session_id,
            session_id,
           count(*)
            count(*)
    from
     from
           v$active_session_history
            v$active_session_history
    where
     where
           session_state=‘WAITING’ and
            session_state=‘WAITING’ and
           SAMPLE_TIME > SYSDATE -- (5/(24*60))
            SAMPLE_TIME > SYSDATE (5/(24*60))
    group by
     group by
           session_id
            session_id
    order by
     order by
           count(*) desc;
            count(*) desc;

                    Copyright 2006 Kyle Hailey    #.16
Top Waiting Session Results


          SESSION_ID
          SESSION_ID   COUNT(*)
                       COUNT(*)
          ---------- ----------
          ---------- ----------
                 272
                 272        224
                            224
                 254
                 254          8
                              8
                 249
                 249          5
                              5
                 276
                 276          5
                              5
                 277
                 277          4
                              4
                 270
                 270          1
                              1




                Copyright 2006 Kyle Hailey   #.17
Top SQL from ASH

select
 select
   ash.SQL_ID , ,
    ash.SQL_ID
  sum(decode(ash.session_state,'ON CPU',1,0))
   sum(decode(ash.session_state,'ON CPU',1,0))       "CPU",
                                                      "CPU",
  sum(decode(ash.session_state,'WAITING',1,0))
   sum(decode(ash.session_state,'WAITING',1,0))      --
  sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0))
   sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0))   "WAIT" , ,
                                                                                        "WAIT"
  sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0))
   sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0))   "IO" , ,
                                                                                        "IO"
   sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"
    sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"
from v$active_session_history ash,
 from v$active_session_history ash,
    v$event_name en
     v$event_name en
where SQL_ID is not NULL and en.event#=ash.event#
 where SQL_ID is not NULL and en.event#=ash.event#
group by sql_id
 group by sql_id
order by sum(decode(session_state,'ON CPU',1,1)) desc
 order by sum(decode(session_state,'ON CPU',1,1)) desc
                                    Copyright 2006 Kyle Hailey                               #.18
Top SQL from ASH Results


SQL_ID
 SQL_ID              CPU
                      CPU   WAITING
                             WAITING        IO
                                             IO     TOTAL
                                                     TOTAL
------------- ---------- ---------- ---------- ----------
 ------------- ---------- ---------- ---------- ----------
4c1xvq9ufwcjc
 4c1xvq9ufwcjc     23386
                    23386         00         00     23386
                                                     23386
6wjw6rz5uvbp3
 6wjw6rz5uvbp3        99
                       99         00        23
                                             23       122
                                                       122
968dm8hr9qd03
 968dm8hr9qd03        97
                       97         00        22
                                             22       119
                                                       119
938jp5gasmrah
 938jp5gasmrah        90
                       90         00        25
                                             25       115
                                                       115
cv8xnv81kf582
 cv8xnv81kf582        42
                       42         00         99        51
                                                        51
6p9bzu19v965k
 6p9bzu19v965k        21
                       21         00         00        21
                                                        21
5zu8pxnun66bu
 5zu8pxnun66bu        15
                       15         00         00        15
                                                        15
db2jr13nup72v
 db2jr13nup72v         99         00         00         99
7ks5gnj38hghv
 7ks5gnj38hghv         88         00         00         88




                       Copyright 2006 Kyle Hailey            #.19
Top Session
 select select
  select
     ash.session_id,
             ash.session_id,
      ash.session_id,
     ash.session_serial#,
             ash.session_serial#,
      ash.session_serial#,
     ash.user_id,
             ash.user_id,
      ash.user_id,
     ash.program,
             ash.program,
      ash.program,
     sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",
             sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",
      sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",
     sum(decode(ash.session_state,'WAITING',1,0)) -- -
             sum(decode(ash.session_state,'WAITING',1,0))
      sum(decode(ash.session_state,'WAITING',1,0))
     sum(decode(ash.session_state,'WAITING',
             sum(decode(ash.session_state,'WAITING',
      sum(decode(ash.session_state,'WAITING',
       decode(en.wait_class,'User I/O',1, 0 ), 0)) 0))"WAITING", , ,
        decode(en.wait_class,'User I/O',1, 0 ),0 ), "WAITING"
               decode(en.wait_class,'User I/O',1, 0))   "WAITING"
     sum(decode(ash.session_state,'WAITING',
             sum(decode(ash.session_state,'WAITING',
      sum(decode(ash.session_state,'WAITING',
       decode(en.wait_class,'User I/O',1, 0 ), 0)) 0))"IO", , ,
        decode(en.wait_class,'User I/O',1, 0 ),0 ), "IO"
               decode(en.wait_class,'User I/O',1, 0))   "IO"
     sum(decode(session_state,'ON CPU',1,1)) "TOTAL"
             sum(decode(session_state,'ON CPU',1,1)) "TOTAL"
      sum(decode(session_state,'ON CPU',1,1)) "TOTAL"
 from v$active_session_history ash,
          from v$active_session_history ash,
  from v$active_session_history ash,
       v$event_name en en
               v$event_name
        v$event_name en
 where en.event# = ash.event#
  where where en.event# = ash.event#
          en.event# = ash.event#
 group by session_id,user_id,session_serial#,program
          group by session_id,user_id,session_serial#,program
  group by session_id,user_id,session_serial#,program
 order by sum(decode(session_state,'ON CPU',1,1))
          order by sum(decode(session_state,'ON CPU',1,1))
  order by sum(decode(session_state,'ON CPU',1,1))
                                 Copyright 2006 Kyle Hailey            #.20
Top Session Results


SESSION_ID SERIAL#    USER_ID PROGRAM                      CPU    WAITING         IO
 SESSION_ID SERIAL#    USER_ID PROGRAM                      CPU    WAITING         IO
---------- ------- ---------- ------------------------- ------- ---------- ----------
 ---------- ------- ---------- ------------------------- ------- ---------- ----------
       247    61970         11 sqlplus                            11698     00      00
        247    61970            sqlplus                            11698
       277        11        00 oracle@labsfrh903 (LGWR)              14    21       00
        277                     oracle@labsfrh903 (LGWR)              14    21
       276        1         0 oracle@labsfrh903 (CKPT)               19    10       0
        276        1         0 oracle@labsfrh903 (CKPT)               19    10       0
       278        11        00 oracle@labsfrh903 (DBW0)              29     00      00
        278                     oracle@labsfrh903 (DBW0)              29
       280        11        00 oracle@labsfrh903 (PMON)              19     00      00
        280                     oracle@labsfrh903 (PMON)              19
       254    22617         55 Executor.exe                          13     00      33
        254    22617            Executor.exe                          13
       255    12877         55 Executor.exe                          11     00      55
        255    12877            Executor.exe                          11
       257    33729         55 Executor.exe                          15     00      11
        257    33729            Executor.exe                          15
       255    13417         55 Executor.exe                          14     00      22
        255    13417            Executor.exe                          14




                                     Copyright 2006 Kyle Hailey                          #.21
Top Session w/ Username
select
 select
     decode(nvl(to_char(s.sid),-1),-1,'DISCONNECTED','CONNECTED')
       decode(nvl(to_char(s.sid),-1),-1,'DISCONNECTED','CONNECTED')
                                    "STATUS",
                                      "STATUS",
     topsession.session_id
       topsession.session_id           "SESSION_ID",
                                         "SESSION_ID",
     u.name "NAME",
       u.name "NAME",
     topsession.program
       topsession.program               "PROGRAM",
                                          "PROGRAM",
     max(topsession.CPU)
       max(topsession.CPU)            "CPU",
                                        "CPU",
     max(topsession.WAITING)
       max(topsession.WAITING) "WAITING","WAITING",
     max(topsession.IO)
       max(topsession.IO)              "IO",
                                        "IO",
     max(topsession.TOTAL)
       max(topsession.TOTAL)            "TOTAL"
                                          "TOTAL"
     from ( ( {previous query} ) ) topsession,
       from {previous query}               topsession,
                                    v$session s,
                                      v$session s,
                                    user$ uu
                                      user$
  where
   where
             u.user# =topsession.user_id and
               u.user# =topsession.user_id and
            /*/* outerjoin to v$session because the session might be disconnected */*/
               outer join to v$session because the session might be disconnected
            topsession.session_id
              topsession.session_id          == s.sid
                                               s.sid   (+) and
                                                        (+) and
            topsession.session_serial# ==s.serial# (+)
              topsession.session_serial# s.serial# (+)
  group by topsession.session_id, topsession.session_serial#, topsession.user_id,
   group by topsession.session_id, topsession.session_serial#, topsession.user_id,
            topsession.program, s.username,s.sid,s.paddr,u.name
              topsession.program, s.username,s.sid,s.paddr,u.name
  order by max(topsession.TOTAL) desc
   order by max(topsession.TOTAL) desc

                                              Copyright 2006 Kyle Hailey                 #.22
Top Session
Finding a Rogue User

STATUS          SESSION_ID NAME       PROGRAM                     CPU    WAITING
 STATUS          SESSION_ID NAME       PROGRAM                     CPU    WAITING IOIO
--------------- ---------- ---------- ------------------------- ----- ---------- ----
 --------------- ---------- ---------- ------------------------- ----- ---------- ----
CONNECTED              247 CPU_Monger ChMgr304.exe              11704          00   00
 CONNECTED              247 CPU_Monger ChMgr304.exe              11704
CONNECTED              277 SYS        oracle@labsfrh903 (LGWR)     14         19    00
 CONNECTED              277 SYS        oracle@labsfrh903 (LGWR)     14         19
CONNECTED              278 SYS        oracle@labsfrh903 (DBW0)     29          00   00
 CONNECTED              278 SYS        oracle@labsfrh903 (DBW0)     29
CONNECTED              276 SYS        oracle@labsfrh903 (CKPT)     18          99   00
 CONNECTED              276 SYS        oracle@labsfrh903 (CKPT)     18
CONNECTED              280 SYS        oracle@labsfrh903 (PMON)     20          00   00
 CONNECTED              280 SYS        oracle@labsfrh903 (PMON)     20
DISCONNECTED           255 SYSTEM     Executor.exe                 11          44   55
 DISCONNECTED           255 SYSTEM     Executor.exe                 11
DISCONNECTED           257 SYSTEM     Executor.exe                 13          00   33
 DISCONNECTED           257 SYSTEM     Executor.exe                 13
DISCONNECTED           255 SYSTEM     Executor.exe                 14          00   22
 DISCONNECTED           255 SYSTEM     Executor.exe                 14
DISCONNECTED           257 SYSTEM     Executor.exe                 13          00   33
 DISCONNECTED           257 SYSTEM     Executor.exe                 13




                                 Copyright 2006 Kyle Hailey                              #.23
Many Ways to Attack Problems
            Confusing
    How to Attack the problem?
    Top SQL?
         Top wait for that SQL?
    Top Waiting Session ?
         Top Waits for that Session
    Top Waits for Database?
       Top Session waiting for that wait
       Top SQL for that wait



            Solution - Graphics

                          Copyright 2006 Kyle Hailey   #.24
Mining Data is Non Trivial
 Many Dimensions to consider
 Constantly Varying time frames
 Luckily 10g automates all of this functionality.
    collectsall of the data
    analyses all the wait events
    reports on bottlenecks
    supplies solutions

 Graphics add tremendous ease and power




                         Copyright 2006 Kyle Hailey   #.25
OEM Perf Page




           Copyright 2006 Kyle Hailey   #.26
ASH Sampling Cheap
 Cost
 1. With PL/SQL it’s less that 1 % CPU with 10 average
    active sessions
 2. DMA - direct memory attach to SGA Using C code 200x
    Cheaper
 3. ASH in 10g should be even cheaper than DMA because
    it’s done in the kernel
 Size
    Circular Buffer - 1M to 128M (~2% of SGA)
    Avg row around 150bytes
    3600 secs in an hour
    ~ ½ Meg per Active Session per hour

                          Copyright 2006 Kyle Hailey      #.27
How ASH works
                                                       V$session_wait
                                                       + v$session +
                                                       extras
                                               MMON/
                                               MMNL



    v$active_session_history             Only writes out 1 in 10 rows
                                         via direct path inserts
                                          wrh$_active_session_history

                             MMON - manageability monitor, AWR
                             M000 – MMON background slave, runs snapshots
                             MMNL - MMON lite, flushes ASH to disk
                      Copyright 2006 Kyle Hailey                        #.28
ASH buffer




Select reads
backwards               Insert point                Insert one direction
-No latching                                        Touch up wait times
-Index on time
-No read consistency


                       Copyright 2006 Kyle Hailey                    #.29
Family of ASH Tables
   Real time
   v$session         (before 10g v$session_wait)

    Last 10 waits
  v$session_wait_history
                                ~2 hours
                   v$active_session_history
                                                        1 week
                             DBA_HIST_ACTIVE_SESS_HISTORY
                                   wrh$active_session_history


                           Copyright 2006 Kyle Hailey           #.30
Oradebug


 Dump to trace file
      SQL> oradebug dump ashdump 5
  SQL> oradebug dump ash 5
      SQL> Alter session set events ‘immediate
  SQL> Alter session set events ‘immediate
           trace name ashdump level 5’;
       tracename ashdump level 5’;

  level 5 = # of minutes
  loader file rdbms/demo/ashldr.ctl




                          Copyright 2006 Kyle Hailey   #.31
INIT.ORA
 statistics_level      = Typical (default)

 PARAMETER                  SESSION_VALUE       INSTANCE_VAL
 ----------------------- ---------- ------------
 _ash_sampling_interval                1000              1000
  milliseconds
 _ash_size                         1048618           1048618
  ASH buffer size
 _ash_enable                          TRUE               TRUE
  Turn on/off ASH sampling, flushing and the V$ views on ASH
 _ash_disk_write_enable               TRUE               TRUE
  Flush to disk
 _ash_disk_filter_ratio                 10                 10
  write 1 in 10 points
 _ash_sample_all                    FALSE                FALSE
  Sample including idle waits

                             Copyright 2006 Kyle Hailey          #.32
10.2 ASH Extras
   Blocking Session !
       BLOCKING_SESSION             RAC event Fixup
       BLOCKING_SESSION_STATUS      Plan Hash Fix up
                                        10gR1 - during parsing no plan,
       BLOCKING_SESSION_SERIAL#        good way to find parsing
  Parameter Names                      problems
        P1TEXT   , P2TEXT, P3TEXT
                                        10gR2 – get plan hash fixup –
                                        good but lose some ability to find
  Wait Grouping                        parsing problems
        WAIT_CLASS
    WAIT_CLASS_ID
  XID
  FORCE_MATCHING_SIGNATURE
     Cursor sharing




02/20/13                                                               #.33
                                                                       33
10.2.0.3 ASH Extras


PLSQL_ENTRY_OBJECT_ID
PLSQL_ENTRY_SUBPROGRAM_ID
PLSQL_OBJECT_ID
PLSQL_SUBPROGRAM_ID



           ALL_PROCEDURES
           where object_id = plsql_object_id
           and subprogram_id = plsql_subprogram_id


02/20/13                                             #.34
                                                     34
PLSQL Tracking
Package/Procedure/SQL tracking 10.2.0.3
      calling_code                      SQL_ID          COUNT(*)
      ----------------------------------------------- ----------
      ORDERENTRY.NEWORDER               0uuqgjq7k12nf        258
      ORDERENTRY.NEWCUSTOMER            0bzhqhhj9mpaa        262
      ORDERENTRY.BROWSEANDUPDATEORDERS 41zu158rqf4kf         301
      ORDERENTRY.NEWORDER               0yas01u2p9ch4        569
      PARSE_SAME                        3vjxpmhhzngu4        874
      ORDERENTRY.BROWSEANDUPDATEORDERS 05s4vdwsf5802        1669

       select
          object_name package||.|| procedure_name, sql_id, count(*)
       from v$active_session_history ash,
             all_procedures procs
        where
              ash.PLSQL_ENTRY_OBJECT_ID = procs.object_id
         and ash.PLSQL_ENTRY_SUBPROGRAM_ID = procs.SUBPROGRAM_ID


02/20/13                                                              #.35
                                                                      35
11.1g ASH extras
SQL Elapsed                                 Operation bit vector – non timed ops
 SQL_EXEC_ID                                IN_CONNECTION_MGMT
 SQL_EXEC_START                             IN_PARSE
                                            IN_HARD_PARSE
SQL Row Source                              IN_SQL_EXECUTION
SQL_PLAN_LINE_ID                            IN_PLSQL_EXECUTION
SQL_PLAN_OPERATION                          IN_PLSQL_RPC
SQL_PLAN_OPTIONS                            IN_PLSQL_COMPILATION
                                            IN_JAVA_EXECUTION
                                            IN_BIND
Which instance requested block?
                                            IN_CURSOR_CLOSE
 REMOTE_INSTANCE#
                                            ETC
Recursive SQL                               CURRENT_ROW#
                                            EVENT#
TOP_LEVEL_SQL_ID                            QC_SESSION_SERIAL#
TOP_LEVEL_SQL_OPCODE                        CONSUMER_GROUP_ID
                                            FLAGS


                            Copyright 2006 Kyle Hailey                      #.36
11.2g ASH extras
Statistics
TM_DELTA_TIME
TM_DELTA_CPU_TIME
TM_DELTA_DB_TIME
DELTA_TIME
DELTA_READ_IO_REQUESTS
DELTA_WRITE_IO_REQUESTS
DELTA_READ_IO_BYTES
DELTA_WRITE_IO_BYTES
DELTA_INTERCONNECT_IO_BYTES
PGA_ALLOCATED
TEMP_SPACE_ALLOCATE




                    Copyright 2006 Kyle Hailey   #.37
ASH Across Versions
                                 When
                                 Who

                                 SQL
                                    ASH
                                     instrumentation
                                     is exploding
                                     across the
                                     versions
                                 Waits



                                Statistics

                                Blocker

10.1 10.2 10.2.0.3 11.1 11.2
                               Copyright 2006 Kyle Hailey   #.38
How Many Active Sessions?


  How much data does ASH Collect ?
  1 CPU means max 1 Avg Active Session unless
   there is a bottleneck
 Big site examples:
  Oracle 4 way RAC internal apps
       10,000 connected, 200 active
  One Site
       3000 connected, 30 Active
  Site
       12,000 connected, 100 active



                           Copyright 2006 Kyle Hailey   #.39
ASH Summary
  Rich & Multidimensional
     Overview of system load
     Drilldowns into problems
            Sql
            Session
            Wait event
       Details information on problem resolution
  Sampling is the future
  Took clean vision to create - Bit of a leap of faith
  Less Accurate but more powerful than past
       Inaccuracies unimportant for the most part
  Feasible since version 7
       You can implement it yourself

  OEM simplifies mining of ASH data
                             Copyright 2006 Kyle Hailey   #.40
Q1

How can you immediately find the top IO consuming SQ
statement in the last 60 seconds


a. v$active_session_history
b. v$sqlstats     answer

c. v$sql          a only

d. v$sqlarea      others
                  b,c,d - only have cumulative values
                  since database startup
                    Copyright 2006 Kyle Hailey     #.41
Q2

Which view can you query directly to
get the specific waits that occurred
30 minutes ago:
a. v$active_session_history
b. v$waitclassmetric
c. v$system_event
d. v$session_wait_history
e. v$waitclassmetric_history
              a only
              b - last 60 seconds only
              c - cumulative info since db startup
              d - last 10 waits only
              e - only wait groups, not wait events, but has
              the history for last hour
                      Copyright 2006 Kyle Hailey           #.42
Q3

ASH (v$active_session_history) is a revolutionary data
source for monitoring and analyzing database
performance. The view v$active_session_history is new
in 10g, but most of the data needed in order to simulate
v$active_session_history by hand has been available
since which version
             b - since version 7 when wait events
a. 6         were introduced along with the view
b. 7         v$session_wait
c. 8
d. 9         which is the foundation for ASH
e. 10
                    Copyright 2006 Kyle Hailey      #.43

Contenu connexe

En vedette

Creating Queue Manager and Queue's in IBM WebSphere Mq
Creating Queue Manager and Queue's in IBM WebSphere MqCreating Queue Manager and Queue's in IBM WebSphere Mq
Creating Queue Manager and Queue's in IBM WebSphere MqRavi Babu
 
Sending and receiving messages in mq queues
Sending and receiving messages in mq queuesSending and receiving messages in mq queues
Sending and receiving messages in mq queuesRavi Babu
 
Oracle 10g Performance: chapter 05 waits intro
Oracle 10g Performance: chapter 05 waits introOracle 10g Performance: chapter 05 waits intro
Oracle 10g Performance: chapter 05 waits introKyle Hailey
 
Oracle 10g Performance: chapter 00 intro live_short
Oracle 10g Performance: chapter 00 intro live_shortOracle 10g Performance: chapter 00 intro live_short
Oracle 10g Performance: chapter 00 intro live_shortKyle Hailey
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuningAbishek V S
 
Oracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsOracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsAsanka Dilruk
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuningYogiji Creations
 
Websphere MQ admin guide
Websphere MQ admin guideWebsphere MQ admin guide
Websphere MQ admin guideRam Babu
 
Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Kernel Training
 
Oracle 11g R2 RAC implementation and concept
Oracle 11g R2 RAC implementation and conceptOracle 11g R2 RAC implementation and concept
Oracle 11g R2 RAC implementation and conceptSantosh Kangane
 
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0Yury Velikanov
 
Websphere MQ (MQSeries) fundamentals
Websphere MQ (MQSeries) fundamentalsWebsphere MQ (MQSeries) fundamentals
Websphere MQ (MQSeries) fundamentalsBiju Nair
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Guy Harrison
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuningGuy Harrison
 

En vedette (14)

Creating Queue Manager and Queue's in IBM WebSphere Mq
Creating Queue Manager and Queue's in IBM WebSphere MqCreating Queue Manager and Queue's in IBM WebSphere Mq
Creating Queue Manager and Queue's in IBM WebSphere Mq
 
Sending and receiving messages in mq queues
Sending and receiving messages in mq queuesSending and receiving messages in mq queues
Sending and receiving messages in mq queues
 
Oracle 10g Performance: chapter 05 waits intro
Oracle 10g Performance: chapter 05 waits introOracle 10g Performance: chapter 05 waits intro
Oracle 10g Performance: chapter 05 waits intro
 
Oracle 10g Performance: chapter 00 intro live_short
Oracle 10g Performance: chapter 00 intro live_shortOracle 10g Performance: chapter 00 intro live_short
Oracle 10g Performance: chapter 00 intro live_short
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuning
 
Oracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsOracle DB Performance Tuning Tips
Oracle DB Performance Tuning Tips
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuning
 
Websphere MQ admin guide
Websphere MQ admin guideWebsphere MQ admin guide
Websphere MQ admin guide
 
Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning
 
Oracle 11g R2 RAC implementation and concept
Oracle 11g R2 RAC implementation and conceptOracle 11g R2 RAC implementation and concept
Oracle 11g R2 RAC implementation and concept
 
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0
Oracle 12c RAC On your laptop Step by Step Implementation Guide 1.0
 
Websphere MQ (MQSeries) fundamentals
Websphere MQ (MQSeries) fundamentalsWebsphere MQ (MQSeries) fundamentals
Websphere MQ (MQSeries) fundamentals
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
 

Plus de Kyle Hailey

Hooks in postgresql by Guillaume Lelarge
Hooks in postgresql by Guillaume LelargeHooks in postgresql by Guillaume Lelarge
Hooks in postgresql by Guillaume LelargeKyle Hailey
 
Performance insights twitch
Performance insights twitchPerformance insights twitch
Performance insights twitchKyle Hailey
 
History of database monitoring
History of database monitoringHistory of database monitoring
History of database monitoringKyle Hailey
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Kyle Hailey
 
Successfully convince people with data visualization
Successfully convince people with data visualizationSuccessfully convince people with data visualization
Successfully convince people with data visualizationKyle Hailey
 
Virtual Data : Eliminating the data constraint in Application Development
Virtual Data :  Eliminating the data constraint in Application DevelopmentVirtual Data :  Eliminating the data constraint in Application Development
Virtual Data : Eliminating the data constraint in Application DevelopmentKyle Hailey
 
DBTA Data Summit : Eliminating the data constraint in Application Development
DBTA Data Summit : Eliminating the data constraint in Application DevelopmentDBTA Data Summit : Eliminating the data constraint in Application Development
DBTA Data Summit : Eliminating the data constraint in Application DevelopmentKyle Hailey
 
Accelerate Develoment with VIrtual Data
Accelerate Develoment with VIrtual DataAccelerate Develoment with VIrtual Data
Accelerate Develoment with VIrtual DataKyle Hailey
 
Delphix and Pure Storage partner
Delphix and Pure Storage partnerDelphix and Pure Storage partner
Delphix and Pure Storage partnerKyle Hailey
 
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Mark Farnam  : Minimizing the Concurrency Footprint of TransactionsMark Farnam  : Minimizing the Concurrency Footprint of Transactions
Mark Farnam : Minimizing the Concurrency Footprint of TransactionsKyle Hailey
 
Dan Norris: Exadata security
Dan Norris: Exadata securityDan Norris: Exadata security
Dan Norris: Exadata securityKyle Hailey
 
Martin Klier : Volkswagen for Oracle Guys
Martin Klier : Volkswagen for Oracle GuysMartin Klier : Volkswagen for Oracle Guys
Martin Klier : Volkswagen for Oracle GuysKyle Hailey
 
Data as a Service
Data as a Service Data as a Service
Data as a Service Kyle Hailey
 
Data Virtualization: Revolutionizing data cloning
Data Virtualization: Revolutionizing data cloningData Virtualization: Revolutionizing data cloning
Data Virtualization: Revolutionizing data cloning Kyle Hailey
 
BGOUG "Agile Data: revolutionizing database cloning'
BGOUG  "Agile Data: revolutionizing database cloning'BGOUG  "Agile Data: revolutionizing database cloning'
BGOUG "Agile Data: revolutionizing database cloning'Kyle Hailey
 
Denver devops : enabling DevOps with data virtualization
Denver devops : enabling DevOps with data virtualizationDenver devops : enabling DevOps with data virtualization
Denver devops : enabling DevOps with data virtualizationKyle Hailey
 
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]Kyle Hailey
 
Jonathan Lewis explains Delphix
Jonathan Lewis explains Delphix Jonathan Lewis explains Delphix
Jonathan Lewis explains Delphix Kyle Hailey
 
Oaktable World 2014 Toon Koppelaars: database constraints polite excuse
Oaktable World 2014 Toon Koppelaars: database constraints polite excuseOaktable World 2014 Toon Koppelaars: database constraints polite excuse
Oaktable World 2014 Toon Koppelaars: database constraints polite excuseKyle Hailey
 

Plus de Kyle Hailey (20)

Hooks in postgresql by Guillaume Lelarge
Hooks in postgresql by Guillaume LelargeHooks in postgresql by Guillaume Lelarge
Hooks in postgresql by Guillaume Lelarge
 
Performance insights twitch
Performance insights twitchPerformance insights twitch
Performance insights twitch
 
History of database monitoring
History of database monitoringHistory of database monitoring
History of database monitoring
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
 
Successfully convince people with data visualization
Successfully convince people with data visualizationSuccessfully convince people with data visualization
Successfully convince people with data visualization
 
Virtual Data : Eliminating the data constraint in Application Development
Virtual Data :  Eliminating the data constraint in Application DevelopmentVirtual Data :  Eliminating the data constraint in Application Development
Virtual Data : Eliminating the data constraint in Application Development
 
DBTA Data Summit : Eliminating the data constraint in Application Development
DBTA Data Summit : Eliminating the data constraint in Application DevelopmentDBTA Data Summit : Eliminating the data constraint in Application Development
DBTA Data Summit : Eliminating the data constraint in Application Development
 
Accelerate Develoment with VIrtual Data
Accelerate Develoment with VIrtual DataAccelerate Develoment with VIrtual Data
Accelerate Develoment with VIrtual Data
 
Delphix and Pure Storage partner
Delphix and Pure Storage partnerDelphix and Pure Storage partner
Delphix and Pure Storage partner
 
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Mark Farnam  : Minimizing the Concurrency Footprint of TransactionsMark Farnam  : Minimizing the Concurrency Footprint of Transactions
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
 
Dan Norris: Exadata security
Dan Norris: Exadata securityDan Norris: Exadata security
Dan Norris: Exadata security
 
Martin Klier : Volkswagen for Oracle Guys
Martin Klier : Volkswagen for Oracle GuysMartin Klier : Volkswagen for Oracle Guys
Martin Klier : Volkswagen for Oracle Guys
 
What is DevOps
What is DevOpsWhat is DevOps
What is DevOps
 
Data as a Service
Data as a Service Data as a Service
Data as a Service
 
Data Virtualization: Revolutionizing data cloning
Data Virtualization: Revolutionizing data cloningData Virtualization: Revolutionizing data cloning
Data Virtualization: Revolutionizing data cloning
 
BGOUG "Agile Data: revolutionizing database cloning'
BGOUG  "Agile Data: revolutionizing database cloning'BGOUG  "Agile Data: revolutionizing database cloning'
BGOUG "Agile Data: revolutionizing database cloning'
 
Denver devops : enabling DevOps with data virtualization
Denver devops : enabling DevOps with data virtualizationDenver devops : enabling DevOps with data virtualization
Denver devops : enabling DevOps with data virtualization
 
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
 
Jonathan Lewis explains Delphix
Jonathan Lewis explains Delphix Jonathan Lewis explains Delphix
Jonathan Lewis explains Delphix
 
Oaktable World 2014 Toon Koppelaars: database constraints polite excuse
Oaktable World 2014 Toon Koppelaars: database constraints polite excuseOaktable World 2014 Toon Koppelaars: database constraints polite excuse
Oaktable World 2014 Toon Koppelaars: database constraints polite excuse
 

Oracle 10g Performance: chapter 01 ash

  • 1. ASH – Active Session History Feel the Power Kyle Hailey http://perfvision.com #.1
  • 2. Why should you care? Because ASH can Change your life …  10g immediately Accessible  Geeks: Via scripts in SQL  Managers : Graphical OEM  Stuck on Oracle 7,8,9 ? … my apologies because 10g rocks, but … no worries, the data is accessible for you too via scripts http://perfvision.com/sash.php Copyright 2006 Kyle Hailey #.2
  • 3. Revolution and an Evolution Oracle 6 … ie the dark ages … there was once the Cache Buffer Hit Ratio Oracle 7 … turned the lights on … Wait Events … hallelujah I can see the light Oracle 10g … ASH has landed (like the wheels on the suitcases) Copyright 2006 Kyle Hailey #.3
  • 4. Sampling New Paradigm  Clear Vision of the future  Use new sampling technology  Lets go of the need to know 100%  Statistical approximation  Cheaper  Richer Multidimensional Data  Identifies  SQL  Sessions  Objects  Machine  User Copyright 2006 Kyle Hailey #.4
  • 5. Identify Players before ASH  Sessions v$sesstat, v$session_event # sessions x (# wait events + statistics)  Example (150 x (800+200) = 150,000 )  SQL  v$sql  Could be 10000s  Takes out latches that compete with other sql executions  Objects Also files v$filestat  V$segstat 9i+  Could be 1000s of objects Expensive ! Copyright 2006 Kyle Hailey #.5
  • 6. ASH Intelligence for the new Millennium  Intelligently Collects Data  Samples once a second  Collects active sessions only  Collects Session/SQL/Wait  More activity, more data collected  Less activity, less data collected  Those old methods collected everything  Obfuscated the problem, too many statistics too late  Costly  Too Granular – once an hour ?! Give me a break  Collects fine grain multidimensional data Copyright 2006 Kyle Hailey #.6
  • 7. ASH Fields SQL> v$active_session_history Name Null? Type SAMPLE_ID NUMBER SAMPLE_TIME TIMESTAMP(3) SESSION_ID NUMBER SESSION_SERIAL# NUMBER USER_ID NUMBER SQL_ID VARCHAR2(13) SQL_CHILD_NUMBER NUMBER SQL_PLAN_HASH_VALUE NUMBER SQL_OPCODE NUMBER SERVICE_HASH NUMBER SESSION_TYPE VARCHAR2(10) SESSION_STATE VARCHAR2(7) QC_SESSION_ID NUMBER QC_INSTANCE_ID NUMBER EVENT VARCHAR2(64) EVENT_ID NUMBER EVENT# NUMBER SEQ# NUMBER P1 NUMBER P2 NUMBER P3 NUMBER WAIT_TIME NUMBER TIME_WAITED NUMBER CURRENT_OBJ# NUMBER CURRENT_FILE# NUMBER CURRENT_BLOCK# NUMBER PROGRAM VARCHAR2(48) MODULE VARCHAR2(48) ACTION VARCHAR2(32) CLIENT_ID Copyright 2006 Kyle Hailey VARCHAR2(64 #.7
  • 8. v$active_session_history When SAMPLE_ID SAMPLE_TIME NUMBER TIMESTAMP(3) SESSION_ID NUMBER SESSION_SERIAL# NUMBER Session USER_ID SERVICE_HASH NUMBER NUMBER SESSION_TYPE VARCHAR2(10) PROGRAM VARCHAR2(64) MODULE VARCHAR2(48) ACTION VARCHAR2(32) CLIENT_ID VARCHAR2(64) State SESSION_STATE VARCHAR2(7) WAIT_TIME NUMBER EVENT VARCHAR2(64) EVENT_ID NUMBER EVENT# NUMBER SEQ# NUMBER Wait P1 NUMBER P2 NUMBER P3 NUMBER WAIT_TIME NUMBER TIME_WAITED NUMBER CURRENT_OBJ# NUMBER CURRENT_FILE# NUMBER CURRENT_BLOCK# NUMBER0 SQL_ID VARCHAR2(13) SQL_CHILD_NUMBER NUMBER SQL SQL_PLAN_HASH_VALUE SQL_OPCODE NUMBER NUMBER QC_SESSION_ID NUMBER QC_INSTANCE_ID NUMBER Duration TIME_WAITED Copyright 2006 Kyle Hailey NUMBER #.8
  • 9. Primary Fields of ASH Activity : Who, What, When, How When SAMPLE_TIME Time Who SESSION_ID Session SESSION_STATE State How EVENT Wait What SQL_ID SQL Copyright 2006 Kyle Hailey #.9
  • 10. Amazing things YOU can do Top SQL Top Consumers Top Resources  SQL ID  Session • CPU  Plan X  User  Object X • Waits  Child#  Module.Action • Event (800*)  Program • I/O  Service • File  Client • Block  Wait • Time And Aggregated over any time Period (32 columns in ASH 10.1) Copyright 2006 Kyle Hailey #.10
  • 11. Multi-dimensional SQL F1qcyh20550cf Package Procedure fj6gjgsshtxyx Plan 0cjsxw5ndqdbc Child # 8t8as9usk11qw dr1rkrznhh95b W St a 10dkqv3kr8xa5 C at its 38zhkf4jdyff4 En PU ist 298wmz1kxjs1m S q: db QL TX ics db fil *Ne – 25 34 36 38 45 63 65 87 fil e s t b row Sessions e ca r e se tt a loc qu ere k/r k en d es co Program Sqlplus Toad t i a re e t n t e l r ad to nt ea c l io d ie n nt User Sys Scott System Ap pl Service ic GL OE IO at io n #.11
  • 12. Groupings – Top Consumer SESSION_ID SESSION_SERIAL# (identify SID reuse) SESSION_TYPE (FOREGROUND,BACKGROUND) USER_ID (SYS, SYSTEM, SCOTT etc) SERVICE_HASH (OE,GL,HR) MODULE.ACTION (PLSQL tagging) CLIENT_ID (identifying users in session pool) PROGRAM (SQL, JDBC, Forms etc) SQL_ID QC_SESSION_ID (Query Coordinator) QC_INSTANCE_ID (RAC) EVENT + P1, P2, P3 CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK# Copyright 2006 Kyle Hailey #.12
  • 13. Top CPU Session Top CPU consuming Session in last 5 minutes Select Select session_id, Who is the rogue session ? session_id, count(*) count(*) from from v$active_session_history v$active_session_history where where session_state= ‘ON CPU‘ and session_state= ‘ON CPU‘ and SAMPLE_TIME > sysdate – (5/(24*60)) SAMPLE_TIME > sysdate – (5/(24*60)) group by group by session_id session_id order by order by count(*) desc; count(*) desc; Copyright 2006 Kyle Hailey #.13
  • 14. Results Top CPU Session SESSION_ID SESSION_ID COUNT(*) COUNT(*) ---------- ---------- ---------- ---------- 257 257 299 299 263 263 62 62 256 256 32 32 264 264 9 9 277 277 3 3 258 258 1 1 Copyright 2006 Kyle Hailey #.14
  • 15. CPU with Bars SESSION_ID SESSION_ID COUNT(*) COUNT(*) % Bar % Bar ---------- ---------- ---------- ------------ ---------- ---------- ---------- ------------ 257 257 299 299 99 |**********| 99 |**********| 263 263 62 62 21 |** 21 |** || 256 256 32 32 11 |* 11 |* || 264 264 99 3 | 3 | || 277 277 33 1 | 1 | || 258 258 11 0 | 0 | || 280 280 11 0 | 0 | || Bar shows 10% increments Copyright 2006 Kyle Hailey #.15
  • 16. Top Waiting Session  Top Waiting Session in last 5 minutes Select Select session_id, session_id, count(*) count(*) from from v$active_session_history v$active_session_history where where session_state=‘WAITING’ and session_state=‘WAITING’ and SAMPLE_TIME > SYSDATE -- (5/(24*60)) SAMPLE_TIME > SYSDATE (5/(24*60)) group by group by session_id session_id order by order by count(*) desc; count(*) desc; Copyright 2006 Kyle Hailey #.16
  • 17. Top Waiting Session Results SESSION_ID SESSION_ID COUNT(*) COUNT(*) ---------- ---------- ---------- ---------- 272 272 224 224 254 254 8 8 249 249 5 5 276 276 5 5 277 277 4 4 270 270 1 1 Copyright 2006 Kyle Hailey #.17
  • 18. Top SQL from ASH select select ash.SQL_ID , , ash.SQL_ID sum(decode(ash.session_state,'ON CPU',1,0)) sum(decode(ash.session_state,'ON CPU',1,0)) "CPU", "CPU", sum(decode(ash.session_state,'WAITING',1,0)) sum(decode(ash.session_state,'WAITING',1,0)) -- sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) "WAIT" , , "WAIT" sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) "IO" , , "IO" sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL" sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL" from v$active_session_history ash, from v$active_session_history ash, v$event_name en v$event_name en where SQL_ID is not NULL and en.event#=ash.event# where SQL_ID is not NULL and en.event#=ash.event# group by sql_id group by sql_id order by sum(decode(session_state,'ON CPU',1,1)) desc order by sum(decode(session_state,'ON CPU',1,1)) desc Copyright 2006 Kyle Hailey #.18
  • 19. Top SQL from ASH Results SQL_ID SQL_ID CPU CPU WAITING WAITING IO IO TOTAL TOTAL ------------- ---------- ---------- ---------- ---------- ------------- ---------- ---------- ---------- ---------- 4c1xvq9ufwcjc 4c1xvq9ufwcjc 23386 23386 00 00 23386 23386 6wjw6rz5uvbp3 6wjw6rz5uvbp3 99 99 00 23 23 122 122 968dm8hr9qd03 968dm8hr9qd03 97 97 00 22 22 119 119 938jp5gasmrah 938jp5gasmrah 90 90 00 25 25 115 115 cv8xnv81kf582 cv8xnv81kf582 42 42 00 99 51 51 6p9bzu19v965k 6p9bzu19v965k 21 21 00 00 21 21 5zu8pxnun66bu 5zu8pxnun66bu 15 15 00 00 15 15 db2jr13nup72v db2jr13nup72v 99 00 00 99 7ks5gnj38hghv 7ks5gnj38hghv 88 00 00 88 Copyright 2006 Kyle Hailey #.19
  • 20. Top Session select select select ash.session_id, ash.session_id, ash.session_id, ash.session_serial#, ash.session_serial#, ash.session_serial#, ash.user_id, ash.user_id, ash.user_id, ash.program, ash.program, ash.program, sum(decode(ash.session_state,'ON CPU',1,0)) "CPU", sum(decode(ash.session_state,'ON CPU',1,0)) "CPU", sum(decode(ash.session_state,'ON CPU',1,0)) "CPU", sum(decode(ash.session_state,'WAITING',1,0)) -- - sum(decode(ash.session_state,'WAITING',1,0)) sum(decode(ash.session_state,'WAITING',1,0)) sum(decode(ash.session_state,'WAITING', sum(decode(ash.session_state,'WAITING', sum(decode(ash.session_state,'WAITING', decode(en.wait_class,'User I/O',1, 0 ), 0)) 0))"WAITING", , , decode(en.wait_class,'User I/O',1, 0 ),0 ), "WAITING" decode(en.wait_class,'User I/O',1, 0)) "WAITING" sum(decode(ash.session_state,'WAITING', sum(decode(ash.session_state,'WAITING', sum(decode(ash.session_state,'WAITING', decode(en.wait_class,'User I/O',1, 0 ), 0)) 0))"IO", , , decode(en.wait_class,'User I/O',1, 0 ),0 ), "IO" decode(en.wait_class,'User I/O',1, 0)) "IO" sum(decode(session_state,'ON CPU',1,1)) "TOTAL" sum(decode(session_state,'ON CPU',1,1)) "TOTAL" sum(decode(session_state,'ON CPU',1,1)) "TOTAL" from v$active_session_history ash, from v$active_session_history ash, from v$active_session_history ash, v$event_name en en v$event_name v$event_name en where en.event# = ash.event# where where en.event# = ash.event# en.event# = ash.event# group by session_id,user_id,session_serial#,program group by session_id,user_id,session_serial#,program group by session_id,user_id,session_serial#,program order by sum(decode(session_state,'ON CPU',1,1)) order by sum(decode(session_state,'ON CPU',1,1)) order by sum(decode(session_state,'ON CPU',1,1)) Copyright 2006 Kyle Hailey #.20
  • 21. Top Session Results SESSION_ID SERIAL# USER_ID PROGRAM CPU WAITING IO SESSION_ID SERIAL# USER_ID PROGRAM CPU WAITING IO ---------- ------- ---------- ------------------------- ------- ---------- ---------- ---------- ------- ---------- ------------------------- ------- ---------- ---------- 247 61970 11 sqlplus 11698 00 00 247 61970 sqlplus 11698 277 11 00 oracle@labsfrh903 (LGWR) 14 21 00 277 oracle@labsfrh903 (LGWR) 14 21 276 1 0 oracle@labsfrh903 (CKPT) 19 10 0 276 1 0 oracle@labsfrh903 (CKPT) 19 10 0 278 11 00 oracle@labsfrh903 (DBW0) 29 00 00 278 oracle@labsfrh903 (DBW0) 29 280 11 00 oracle@labsfrh903 (PMON) 19 00 00 280 oracle@labsfrh903 (PMON) 19 254 22617 55 Executor.exe 13 00 33 254 22617 Executor.exe 13 255 12877 55 Executor.exe 11 00 55 255 12877 Executor.exe 11 257 33729 55 Executor.exe 15 00 11 257 33729 Executor.exe 15 255 13417 55 Executor.exe 14 00 22 255 13417 Executor.exe 14 Copyright 2006 Kyle Hailey #.21
  • 22. Top Session w/ Username select select decode(nvl(to_char(s.sid),-1),-1,'DISCONNECTED','CONNECTED') decode(nvl(to_char(s.sid),-1),-1,'DISCONNECTED','CONNECTED') "STATUS", "STATUS", topsession.session_id topsession.session_id "SESSION_ID", "SESSION_ID", u.name "NAME", u.name "NAME", topsession.program topsession.program "PROGRAM", "PROGRAM", max(topsession.CPU) max(topsession.CPU) "CPU", "CPU", max(topsession.WAITING) max(topsession.WAITING) "WAITING","WAITING", max(topsession.IO) max(topsession.IO) "IO", "IO", max(topsession.TOTAL) max(topsession.TOTAL) "TOTAL" "TOTAL" from ( ( {previous query} ) ) topsession, from {previous query} topsession, v$session s, v$session s, user$ uu user$ where where u.user# =topsession.user_id and u.user# =topsession.user_id and /*/* outerjoin to v$session because the session might be disconnected */*/ outer join to v$session because the session might be disconnected topsession.session_id topsession.session_id == s.sid s.sid (+) and (+) and topsession.session_serial# ==s.serial# (+) topsession.session_serial# s.serial# (+) group by topsession.session_id, topsession.session_serial#, topsession.user_id, group by topsession.session_id, topsession.session_serial#, topsession.user_id, topsession.program, s.username,s.sid,s.paddr,u.name topsession.program, s.username,s.sid,s.paddr,u.name order by max(topsession.TOTAL) desc order by max(topsession.TOTAL) desc Copyright 2006 Kyle Hailey #.22
  • 23. Top Session Finding a Rogue User STATUS SESSION_ID NAME PROGRAM CPU WAITING STATUS SESSION_ID NAME PROGRAM CPU WAITING IOIO --------------- ---------- ---------- ------------------------- ----- ---------- ---- --------------- ---------- ---------- ------------------------- ----- ---------- ---- CONNECTED 247 CPU_Monger ChMgr304.exe 11704 00 00 CONNECTED 247 CPU_Monger ChMgr304.exe 11704 CONNECTED 277 SYS oracle@labsfrh903 (LGWR) 14 19 00 CONNECTED 277 SYS oracle@labsfrh903 (LGWR) 14 19 CONNECTED 278 SYS oracle@labsfrh903 (DBW0) 29 00 00 CONNECTED 278 SYS oracle@labsfrh903 (DBW0) 29 CONNECTED 276 SYS oracle@labsfrh903 (CKPT) 18 99 00 CONNECTED 276 SYS oracle@labsfrh903 (CKPT) 18 CONNECTED 280 SYS oracle@labsfrh903 (PMON) 20 00 00 CONNECTED 280 SYS oracle@labsfrh903 (PMON) 20 DISCONNECTED 255 SYSTEM Executor.exe 11 44 55 DISCONNECTED 255 SYSTEM Executor.exe 11 DISCONNECTED 257 SYSTEM Executor.exe 13 00 33 DISCONNECTED 257 SYSTEM Executor.exe 13 DISCONNECTED 255 SYSTEM Executor.exe 14 00 22 DISCONNECTED 255 SYSTEM Executor.exe 14 DISCONNECTED 257 SYSTEM Executor.exe 13 00 33 DISCONNECTED 257 SYSTEM Executor.exe 13 Copyright 2006 Kyle Hailey #.23
  • 24. Many Ways to Attack Problems Confusing  How to Attack the problem?  Top SQL?  Top wait for that SQL?  Top Waiting Session ?  Top Waits for that Session  Top Waits for Database?  Top Session waiting for that wait  Top SQL for that wait Solution - Graphics Copyright 2006 Kyle Hailey #.24
  • 25. Mining Data is Non Trivial  Many Dimensions to consider  Constantly Varying time frames  Luckily 10g automates all of this functionality.  collectsall of the data  analyses all the wait events  reports on bottlenecks  supplies solutions  Graphics add tremendous ease and power Copyright 2006 Kyle Hailey #.25
  • 26. OEM Perf Page Copyright 2006 Kyle Hailey #.26
  • 27. ASH Sampling Cheap Cost 1. With PL/SQL it’s less that 1 % CPU with 10 average active sessions 2. DMA - direct memory attach to SGA Using C code 200x Cheaper 3. ASH in 10g should be even cheaper than DMA because it’s done in the kernel Size  Circular Buffer - 1M to 128M (~2% of SGA)  Avg row around 150bytes  3600 secs in an hour  ~ ½ Meg per Active Session per hour Copyright 2006 Kyle Hailey #.27
  • 28. How ASH works V$session_wait + v$session + extras MMON/ MMNL v$active_session_history Only writes out 1 in 10 rows via direct path inserts wrh$_active_session_history MMON - manageability monitor, AWR M000 – MMON background slave, runs snapshots MMNL - MMON lite, flushes ASH to disk Copyright 2006 Kyle Hailey #.28
  • 29. ASH buffer Select reads backwards Insert point Insert one direction -No latching Touch up wait times -Index on time -No read consistency Copyright 2006 Kyle Hailey #.29
  • 30. Family of ASH Tables Real time v$session (before 10g v$session_wait) Last 10 waits v$session_wait_history ~2 hours v$active_session_history 1 week DBA_HIST_ACTIVE_SESS_HISTORY wrh$active_session_history Copyright 2006 Kyle Hailey #.30
  • 31. Oradebug  Dump to trace file SQL> oradebug dump ashdump 5 SQL> oradebug dump ash 5 SQL> Alter session set events ‘immediate SQL> Alter session set events ‘immediate trace name ashdump level 5’; tracename ashdump level 5’; level 5 = # of minutes loader file rdbms/demo/ashldr.ctl Copyright 2006 Kyle Hailey #.31
  • 32. INIT.ORA statistics_level = Typical (default) PARAMETER SESSION_VALUE INSTANCE_VAL ----------------------- ---------- ------------ _ash_sampling_interval 1000 1000 milliseconds _ash_size 1048618 1048618 ASH buffer size _ash_enable TRUE TRUE Turn on/off ASH sampling, flushing and the V$ views on ASH _ash_disk_write_enable TRUE TRUE Flush to disk _ash_disk_filter_ratio 10 10 write 1 in 10 points _ash_sample_all FALSE FALSE Sample including idle waits Copyright 2006 Kyle Hailey #.32
  • 33. 10.2 ASH Extras  Blocking Session !  BLOCKING_SESSION RAC event Fixup  BLOCKING_SESSION_STATUS Plan Hash Fix up 10gR1 - during parsing no plan,  BLOCKING_SESSION_SERIAL# good way to find parsing Parameter Names problems  P1TEXT , P2TEXT, P3TEXT 10gR2 – get plan hash fixup – good but lose some ability to find Wait Grouping parsing problems  WAIT_CLASS  WAIT_CLASS_ID XID FORCE_MATCHING_SIGNATURE  Cursor sharing 02/20/13 #.33 33
  • 34. 10.2.0.3 ASH Extras PLSQL_ENTRY_OBJECT_ID PLSQL_ENTRY_SUBPROGRAM_ID PLSQL_OBJECT_ID PLSQL_SUBPROGRAM_ID ALL_PROCEDURES where object_id = plsql_object_id and subprogram_id = plsql_subprogram_id 02/20/13 #.34 34
  • 35. PLSQL Tracking Package/Procedure/SQL tracking 10.2.0.3 calling_code SQL_ID COUNT(*) ----------------------------------------------- ---------- ORDERENTRY.NEWORDER 0uuqgjq7k12nf 258 ORDERENTRY.NEWCUSTOMER 0bzhqhhj9mpaa 262 ORDERENTRY.BROWSEANDUPDATEORDERS 41zu158rqf4kf 301 ORDERENTRY.NEWORDER 0yas01u2p9ch4 569 PARSE_SAME 3vjxpmhhzngu4 874 ORDERENTRY.BROWSEANDUPDATEORDERS 05s4vdwsf5802 1669 select object_name package||.|| procedure_name, sql_id, count(*) from v$active_session_history ash, all_procedures procs where ash.PLSQL_ENTRY_OBJECT_ID = procs.object_id and ash.PLSQL_ENTRY_SUBPROGRAM_ID = procs.SUBPROGRAM_ID 02/20/13 #.35 35
  • 36. 11.1g ASH extras SQL Elapsed Operation bit vector – non timed ops SQL_EXEC_ID IN_CONNECTION_MGMT SQL_EXEC_START IN_PARSE IN_HARD_PARSE SQL Row Source IN_SQL_EXECUTION SQL_PLAN_LINE_ID IN_PLSQL_EXECUTION SQL_PLAN_OPERATION IN_PLSQL_RPC SQL_PLAN_OPTIONS IN_PLSQL_COMPILATION IN_JAVA_EXECUTION IN_BIND Which instance requested block? IN_CURSOR_CLOSE REMOTE_INSTANCE# ETC Recursive SQL CURRENT_ROW# EVENT# TOP_LEVEL_SQL_ID QC_SESSION_SERIAL# TOP_LEVEL_SQL_OPCODE CONSUMER_GROUP_ID FLAGS Copyright 2006 Kyle Hailey #.36
  • 38. ASH Across Versions When Who SQL ASH instrumentation is exploding across the versions Waits Statistics Blocker 10.1 10.2 10.2.0.3 11.1 11.2 Copyright 2006 Kyle Hailey #.38
  • 39. How Many Active Sessions?  How much data does ASH Collect ?  1 CPU means max 1 Avg Active Session unless there is a bottleneck Big site examples:  Oracle 4 way RAC internal apps  10,000 connected, 200 active  One Site  3000 connected, 30 Active  Site  12,000 connected, 100 active Copyright 2006 Kyle Hailey #.39
  • 40. ASH Summary  Rich & Multidimensional  Overview of system load  Drilldowns into problems  Sql  Session  Wait event  Details information on problem resolution  Sampling is the future  Took clean vision to create - Bit of a leap of faith  Less Accurate but more powerful than past  Inaccuracies unimportant for the most part  Feasible since version 7  You can implement it yourself  OEM simplifies mining of ASH data Copyright 2006 Kyle Hailey #.40
  • 41. Q1 How can you immediately find the top IO consuming SQ statement in the last 60 seconds a. v$active_session_history b. v$sqlstats answer c. v$sql a only d. v$sqlarea others b,c,d - only have cumulative values since database startup Copyright 2006 Kyle Hailey #.41
  • 42. Q2 Which view can you query directly to get the specific waits that occurred 30 minutes ago: a. v$active_session_history b. v$waitclassmetric c. v$system_event d. v$session_wait_history e. v$waitclassmetric_history a only b - last 60 seconds only c - cumulative info since db startup d - last 10 waits only e - only wait groups, not wait events, but has the history for last hour Copyright 2006 Kyle Hailey #.42
  • 43. Q3 ASH (v$active_session_history) is a revolutionary data source for monitoring and analyzing database performance. The view v$active_session_history is new in 10g, but most of the data needed in order to simulate v$active_session_history by hand has been available since which version b - since version 7 when wait events a. 6 were introduced along with the view b. 7 v$session_wait c. 8 d. 9 which is the foundation for ASH e. 10 Copyright 2006 Kyle Hailey #.43

Notes de l'éditeur

  1. Sampling is a leap in performance tuning technology. It took a clear vision of the future and a bit of a leap of faith to let go of the compulsive need to have exact measurements and instead embrace sampling a technology that statistically approximates the same value with little loss of accuracy but at the same time brings a much great wealth of information necessary for analyzing the performance of a database.
  2. WAIT_TIME is time of last wait, > 0 , means on CPU TIME_WAITED is the actual wait time
  3. Select session_id, session_serial# , count(*) , round((count(*)*100)/(5*60),0) "%", lpad('*',round((count(*)*10)/(5*60),0),'*') "Bar" from v$active_session_history where session_state= 'ON CPU' and SAMPLE_TIME > sysdate - (5/(24*60)) group by session_id, session_serial# order by count(*) desc /
  4. Graphics – humans can process 400,000 times as much data graphically as textually Think of a map of the US and all the counties with birth rates colored from low to high. It’s a massive about of information textually but it can all be seen on one page of a map Select session_id, session_serial# , count(*) , round((count(*)*100)/(5*60),0) "%", lpad('*',round((count(*)*10)/(5*60),0),'*') "Bar" from v$active_session_history where session_state= 'ON CPU' and SAMPLE_TIME > sysdate - (5/(24*60)) group by session_id, session_serial# order by count(*) desc /
  5. ASH _ash_enable = false; [ A dynamic parameter will turn off ASH sampling, flushing and the V$ views on ASH ] ADDM _addm_auto_enable = false; [ A dynamic parameter to turn off automatic ADDM runs after every AWR snapshot ] AWR "_swrf_mmon_flush" = FALSE ; AWR metrics "_swrf_mmon_metrics" = FALSE ; METRICS DB Feature Usage "_swrf_mmon_dbfus" = FALSE ; DB Feature Usage "_swrf_on_disk_enabled" = FALSE ; disable all (on disk, including manual) AWR operations:
  6. set linesize 120 col entry_package for a25 col entry_procedure for a25 col cur_package for a25 col cur_procedure for a25 col calling_code for a70 select procs1.object_name || decode(procs1.procedure_name,'','','.')|| procs1.procedure_name ||' '|| decode(procs2.object_name,procs1.object_name,'',procs2.object_name) || decode(procs2.procedure_name,procs1.procedure_name,'', decode(procs2.procedure_name,'','',null,'','.')||procs2.procedure_name) "calling_code", sql_id, count(*) from v$active_session_history ash, all_procedures procs1, all_procedures procs2 where ash.PLSQL_ENTRY_OBJECT_ID = procs1.object_id (+) and ash.PLSQL_ENTRY_SUBPROGRAM_ID = procs1.SUBPROGRAM_ID (+) and ash.PLSQL_OBJECT_ID = procs2.object_id (+) and ash.PLSQL_SUBPROGRAM_ID = procs2.SUBPROGRAM_ID (+) and ash.sample_time > sysdate - &minutes/(60*24) group by procs1.object_name, procs1.procedure_name, procs2.object_name, procs2.procedure_name,sql_id order by count(*) /
  7. answer a only others b - last 60 seconds only c - cumulative info since db startup d - last 10 waits only e - only wait groups, not wait events, but has the history for last hour 8 ==================================================================== Chapt 1 ASH ASH (v$active_session_history) is a revolutionary data source for monitoring and analyzing database performance. The view v$active_session_history is new in 10g, but most of the data needed in order to simulate v$active_session_history by hand has been available since which version a. 6 b. 7 c. 8 d. 9 e. 10 answer b - since version 7 when wait events were introduced along with the view v$session_wait which is the foundation for ASH 4 ==================================================================== Chapt 1 ASH How can immediate find the top IO consuming SQL statement in the last 60 seconds a. v$active_session_history b. v$sqlstats c. v$sql d. v$sqlarea answer a only others b,c,d - only have cumulative values since database startup
  8. answer 4 ==================================================================== Chapt 1 ASH How can immediate find the top IO consuming SQL statement in the last 60 seconds a. v$active_session_history b. v$sqlstats c. v$sql d. v$sqlarea answer a only others b,c,d - only have cumulative values since database startup