SlideShare une entreprise Scribd logo
1  sur  42
Advanced Oracle Troubleshooting
           No magic is needed,
      systematic approach will do


              Tanel Põder
      http://www.tanelpoder.com
Introduction
• About me:
        Occupation:                  DBA, researcher, consultant
        Expertise:                   Oracle internals geek,
                                     End-to-end performance &
                                     scalability, troubleshooting
        Oracle experience:           12+ years as DBA
        Certification:               OCM (2002) OCP (1999)
        Professional affiliations:   OakTable Network

        Blog:                        http://blog.tanelpoder.com
        Seminar:                     http://blog.tanelpoder.com/seminar/




Tanel Poder
Introduction
• About this presentation:
        Systematic approach, rather than methodology
        Use right tools for right problems
        Break complex problems down to simple problems
        Therefore, use simple tools for simple problems
        In other words, use a systematic approach and life will be
        easier!


• Less slides, more action!

• All scripts used here are freely available:
        http://www.tanelpoder.com

Tanel Poder
Metalink forum thread example:
 Query is taking long time to complete--Need urgent help
 From: …………… 05-Jun-08 08:40
 Subject: Re : Query is taking long time to complete--Need urgent help

 Posting TKPROF may help.

 --------------------------------------------------------------------------------

 From: …………… 05-Jun-08 21:33
 Subject: Re : Query is taking long time to complete--Need urgent help


 Just a hunch, but try changing optimizer mode to FIRST_ROWS.

 --------------------------------------------------------------------------------

 From: …………… 06-Jun-08 03:08
 Subject: Re : Query is taking long time to complete--Need urgent help

 Hi,
 Please try using the HINTS like FIRST_ROWS or USE_HASH. This may solve the problem.



© 2008 Tanel Poder                             http://www.tanelpoder.com               4
Simple (but common) question:




What the $#*&%! is that session doing?




Tanel Poder
Non-systematic troubleshooting
•    Check alert.log…
•    Check for disk and tablespace free space…
•    Check for locks…
•    Check for xyz…

    quot;We did a healthcheck and everything looks OK!quot;



                ?????!
Tanel Poder
Semi-systematic troubleshooting
• Quick check for usual suspects
        System load, locks, etc…


• Look into Statspack (or AWR)…

• Enable sql_trace…

                         …then what?




Tanel Poder
Systematic troubleshooting




                        Demo




Tanel Poder
Troubleshooting approaches
• How do you solve problems?

 a)             Change                              Problem
                            Did it help?
               something                             fixed ?




 b)
              Understand

                                                        Problem
                                           Manage
                                                       fixed and
                                 Sure?     change
                                                       prevented
               Measure



Tanel Poder
Non-Systematic approach!


              Users     Users     Users   Users   Users    Users     Users      Users




       locks                                                              Statspack
                            v$latch                    disk space

                                              ?
               vmstat
                                                                    alert.log
                                free memory        optimizer
                                                   statistics



Tanel Poder
Systematic approach!


                      User X
              Users             Users     Users    Users   Users   Users   Users
                         Users
                           Users




         Session               V$SESSION_WAIT, V$SESSION_EVENT, V$SESSTAT
                      SID
         Server
                               process stack sampling
                      SPID
         process




Tanel Poder
Systematic troubleshooting
• Understand the quot;flowquot; of a server process

• …and how to measure it

• …then measure it

• …step by step

• …using right tool at right step

• ...fix the problem once you understand it
Tanel Poder
Right tools for measuring right problems
Detail level
                                                                  sw.sql / se.sql
                Entry point                 Wait / CPU
                                                                  snapper.sql
                                             profile
                                                                  Sesspack


               sample                                            u.sql
                                             Cursor
               v$session.sql_id                                  sql.sql
                                            execution
               sql_hash_value                                    sqlt.sql
                                             profile



                              PL/SQL code                                     snapper.sql
                                                          Performance
     dbms_profiler             execution                                      Sesspack
                                                         counter profile
                                 profile


     xms.sql                      SQL
                                                        Kernel function       stack sampling
     xmsh.sql                  rowsource
                                                          execution           pstack
     dbms_xplan                 execution
                                                            profile
     “allstats last”             profile

Tanel Poder
sw.sql and Snapper demo
SQL> @sw 114

    SID STATE   EVENT                                          SEQ# SEC_IN_WAIT         P1         P2         P3 P1TRANSL
------- ------- ---------------------------------------- ---------- ----------- ---------- ---------- ---------- ----------------------
    114 WAITING enq: TX - row lock contention                    21           9 1415053318     131081       2381 0x54580006: TX mode 6

SQL> @sw &mysid

    SID STATE   EVENT                                          SEQ# SEC_IN_WAIT         P1         P2         P3 P1TRANSL
------- ------- ---------------------------------------- ---------- ----------- ---------- ---------- ---------- ----------------------
    107 WORKING On CPU / runqueue                                89           0 1413697536          1          0

SQL>
SQL> @sn 5 &mysid

-- Session Snapper v1.06 by Tanel Poder ( http://www.tanelpoder.com )

---------------------------------------------------------------------------------------------------------------------------------------------
HEAD,     SID, SNAPSHOT START   , SECONDS, TYPE, STATISTIC                                ,         DELTA, DELTA/SEC,      HDELTA, HDELTA/SEC
---------------------------------------------------------------------------------------------------------------------------------------------
DATA,       9, 20080221 22:05:08,        5, STAT, recursive calls                         ,             1,          0,          1,         .2
DATA,       9, 20080221 22:05:08,        5, STAT, recursive cpu usage                     ,             1,          0,          1,         .2
DATA,       9, 20080221 22:05:08,        5, STAT, session pga memory max                  ,         25292,       5058,     25.29k,      5.06k
DATA,       9, 20080221 22:05:08,        5, STAT, calls to get snapshot scn: kcmgss       ,             1,          0,          1,         .2
DATA,       9, 20080221 22:05:08,        5, STAT, workarea executions - optimal           ,            18,          4,         18,        3.6
DATA,       9, 20080221 22:05:08,        5, STAT, execute count                           ,             1,          0,          1,         .2
DATA,       9, 20080221 22:05:08,        5, STAT, sorts (memory)                          ,            11,          2,         11,        2.2
DATA,       9, 20080221 22:05:08,        5, STAT, sorts (rows)                            ,          1904,        381,       1.9k,      380.8
DATA,       9, 20080221 22:05:08,        5, WAIT, PL/SQL lock timer                       ,       4999649,     999930,         5s,   999.93ms
-- End of snap 1

PL/SQL procedure successfully completed.




Tanel Poder
If this doesn't help…




              …Where to look next?




Tanel Poder
Session troubleshooting sequence


1. Oracle Wait Interface - response TIME!

                          ?
2. v$sesstat performance counters - hints, indicators
                          ?
3. Process stack - truth about process execution

                         !!!
Tanel Poder
Process stack demos
$ pstack 5855
#0 0x00c29402    in   __kernel_vsyscall ()
#1 0x005509e4    in   semtimedop () from /lib/libc.so.6
#2 0x0e5769b7    in   sskgpwwait ()
#3 0x0e575946    in   skgpwwait ()
#4 0x0e2c3adc    in   ksliwat ()
                                         Where to look up the meaning of Oracle kernel
#5 0x0e2c3449    in   kslwaitctx. ()
                                         function names?
#6 0x0b007261    in   kjusuc ()
#7 0x0c8a7961    in   ksipgetctx ()
#8 0x0e2d4dec    in   ksqcmi ()
#9 0x0e2ce9b8    in   ksqgtlctx ()
                                             1) Metalink:
#10 0x0e2cd214   in   ksqgelctx. ()
#11 0x08754afa   in   ktcwit1 ()
                                                   175982.1 ORA-600 Lookup Error Categories
#12 0x0e39b2a8   in   kdddgb ()
#13 0x08930c80   in   kdddel ()
                                                   453521.1 ORA-04031 “KSFQ Buffers” ksmlgpalloc
#14 0x0892af0f   in   kaudel ()
#15 0x08c3d21a   in   delrow ()
                                                   Search: <function> quot;executable entry point”
#16 0x08e6ce16   in   qerdlFetch ()
#17 0x08c403c5   in   delexe ()
                                             2) Oracle views
#18 0x0e3c3fa9   in   opiexe ()
#19 0x08b54500   in   kpoal8 ()
                                                   v$latch_misses (lm.sql)
#20 0x0e3be673   in   opiodr ()
#21 0x0e53628a   in   ttcpip ()
                                                   v$latchholder (latchprofx.sql)
#22 0x089a87ab   in   opitsk ()
#23 0x089aaa00   in   opiino ()
                                                   v$fixed_view_definition (d.sql, f.sql)
#24 0x0e3be673   in   opiodr ()
#25 0x089a4e76   in   opidrv ()
                                             3) Internet search
#26 0x08c1626f   in   sou2o ()
#27 0x08539aeb   in   opimai_real ()
#28 0x08c19a42   in   ssthrdmain ()
#29 0x08539a68   in   main ()


Tanel Poder
Getting stack traces
• OS stack dumper
        pstack - Solaris, Linux, HP-UX
        procstack - AIX
        gdb bt, mdb $c
        Procwatcher (Metalink note: 459694.1)

• Windows
        windbg, procexp - but no symbolic function names in
        oracle.exe :(

• Oracle internal
        oradebug short_stack
        oradebug dump errorstack 1
        alter session set events '942 trace name errorstack'
Tanel Poder
Troubleshooting SQL plan execution




...first requires understanding how SQL is executed!
What is an execution plan?
• For Oracle server:
     Parsed, optimized and compiled SQL code kept inside library cache


• For DBAs and developers:
     Text or graphical representation of SQL execution flow


• Often known as explain plan
     To be correct in terms, explain plan is just a tool, command in Oracle
     Explain plan outputs textual representation of execution plan into plan
     table
     DBAs/developers report human readable output from plan table
One slide for getting execution plan
•   Starting from 9.2 the recommended way is:
       explain plan for <statement>
       select * from table(dbms_xplan.display)
•   In 10g
       the autotrace also uses dbms_xplan
       set autotrace on
       or select * from table(dbms_xplan.display_cursor())


•   In 11g
       DBMS_SQLTUNE.REPORT_SQL_MONITOR


•   Other methods
       sql_trace / event 10046 trace + tkprof utility
       v$sql_plan
       setting event 10132 at level 1
       3rd party tools (which use explain plan anyway)
Parse stages
•   Syntactic check
       Syntax, keywords, sanity




                                                                               soft parse
•   Semantic check
       Whether objects referenced exist, are accessible (by permissions) and
       are usable

•   View merging
       Queries are written to reference base tables
       Can merge both stored views and inline views




                                                                               hard parse
•   Query transformation
       Transitivity, etc (example: if a=1 and a=b then b=1)

•   Optimization
•   Query execution plan (QEP) generation
•   Loading SQL and execution plan in library cache
SQL execution data flow - basics
------------------------------------------
                               Execution plan
| Id | Operation           | Name         |
------------------------------------------
                                                                       SELECT
|   0 | SELECT STATEMENT   |              |
                                                                                        cursor
|* 1 | HASH JOIN           |              |
                                                                       processor
|* 2 |    TABLE ACCESS FULL| DEPARTMENTS |
|* 3 |    TABLE ACCESS FULL| EMPLOYEES    |
                                                                                                    application
------------------------------------------




                                                                          row source
SELECT                Query
    E.LAST_NAME,
    D.DEPARTMENT_NAME
FROM
    EMPLOYEES E,
    DEPARTMENTS D
WHERE
    E.DEPARTMENT_ID =
                                                                     HASH JOIN
      D.DEPARTMENT_ID
                                  FI
                                     LT


AND D.DEPARTMENT_NAME =




                                                                                                      ER
                                                                                       ta
                                       ER


      'Sales'
                                                                                          bl




                                                                                                    LT
                                                                                             e
AND E.SALARY > 2000;
                                                                                       r o ac
                                                                 e




                                                                                                 FI
                                                              rc                          w ce
                                               an           u
                                                       so                                     so s s
                                          sc                                                    ur fu
                                      e            w
                                    bl                                                            ce l l
                                                ro
                                 ta
                        DEPARTMENTS                                                         EMPLOYEES

                                    http://www.tanelpoder.com
SQL execution data flow - multitable joins
SELECT                     Multiple joins
    E.LAST_NAME,
    D.DEPARTMENT_NAME,
                                                                                SELECT
                                                                                                cursor
    L.CITY
                                                                                processor
FROM
                                                                                                                     app.
    EMPLOYEES E,




                                                                                   row source
    DEPARTMENTS D,
    LOCATIONS L
WHERE
    E.DEPARTMENT_ID = D.DEPARTMENT_ID
AND D.DEPARTMENT_NAME = 'Sales'
AND D.LOCATION_ID = L.LOCATION_IID
AND E.SALARY > 2000;
                                                                              HASH JOIN         ro
                                                                    e                              w
                                                                  rc                                   so
                                                              u
Only two row sources can be                                 so                                            u   rc
                                                        w
joined together at a time                                                                                        e
                                                     ro
Row sources pass their data
                                                                                                EMPLOYEES
quot;upquot; the execution plan tree                       NL
                                                  JOIN
The join order is determined
during optimization phase
                                                         ro
                                              e             w
                                            rc                  so
                                        u
                                      so                           u   rc
                                  w                                       e
                               ro

                       DEPARTMENTS                           LOCATIONS

                                             http://www.tanelpoder.com
Reading execution plans: Rule 1
• Parent operations get input only from their children
-------------------------------------------------------------------------
                                                   Execution plan
| Id | Operation                                     | Name             |
                                                     structure
-------------------------------------------------------------------------
|   0 | SELECT STATEMENT                             |                  |
|* 1 |    FILTER                                     |                  |
|   2|      NESTED LOOPS OUTER                       |                  |
|* 3 |        HASH JOIN OUTER                        |                  |
|   4|          NESTED LOOPS OUTER                   |                  |
|   5|            NESTED LOOPS OUTER                 |                  |
|* 6 |              HASH JOIN                        |                  |
|   7|                TABLE ACCESS FULL              | USER$            |
|   8|                NESTED LOOPS                   |                  |
|* 9 |                  HASH JOIN                    |                  |
| 10 |                    MERGE JOIN CARTESIAN       |                  |
|* 11 |                     HASH JOIN                |                  |
|* 12 |                       FIXED TABLE FULL       | X$KSPPI          |
| 13 |                        FIXED TABLE FULL       | X$KSPPCV         |
| 14 |                      BUFFER SORT              |                  |
| 15 |                        TABLE ACCESS FULL      | TS$              |
|* 16 |                   TABLE ACCESS FULL          | TAB$             |
|* 17 |                 TABLE ACCESS BY INDEX ROWID | OBJ$              |
|* 18 |                   INDEX UNIQUE SCAN          | I_OBJ1           |
| 19 |              TABLE ACCESS BY INDEX ROWID      | OBJ$             |
|* 20 |               INDEX UNIQUE SCAN              | I_OBJ1           |
| 21 |            TABLE ACCESS BY INDEX ROWID        | OBJ$             |
|* 22 |             INDEX UNIQUE SCAN                | I_OBJ1           |
| 23 |          TABLE ACCESS FULL                    | USER$            |
| 24 |        TABLE ACCESS CLUSTER                   | SEG$             |
|* 25 |         INDEX UNIQUE SCAN                    | I_FILE#_BLOCK# |
| 26 |      NESTED LOOPS                             |                  |
|* 27 |       INDEX RANGE SCAN                       | I_OBJAUTH1       |
|* 28 |       FIXED TABLE FULL                       | X$KZSRO          |
|* 29 |         FIXED TABLE FULL                     | X$KZSPR          |
-------------------------------------------------------------------------

                                        http://www.tanelpoder.com
Reading execution plans: Rule 2
• Data access starts from the first line without children
 -------------------------------------------------------------------------
                                                    Execution plan
 | Id | Operation                                     | Name             |
                                                      structure
 -------------------------------------------------------------------------
 |   0 | SELECT STATEMENT                             |                  |
 |* 1 |    FILTER                                     |                  |
 |   2|      NESTED LOOPS OUTER                       |                  |
 |* 3 |        HASH JOIN OUTER                        |                  |
 |   4|          NESTED LOOPS OUTER                   |                  |
 |   5|            NESTED LOOPS OUTER                 |                  |
 |* 6 |              HASH JOIN                        |                  |
 |   7|                TABLE ACCESS FULL              | USER$            |
                                                                             First operation with no children
 |   8|                NESTED LOOPS                   |                  |
                                                                             (leaf operation) accesses data
 |* 9 |                  HASH JOIN                    |                  |
 | 10 |                    MERGE JOIN CARTESIAN       |                  |
 |* 11 |                     HASH JOIN                |                  |
 |* 12 |                       FIXED TABLE FULL       | X$KSPPI          |
 | 13 |                        FIXED TABLE FULL       | X$KSPPCV         |
 | 14 |                      BUFFER SORT              |                  |
 | 15 |                        TABLE ACCESS FULL      | TS$              |
 |* 16 |                   TABLE ACCESS FULL          | TAB$             |
 |* 17 |                 TABLE ACCESS BY INDEX ROWID | OBJ$              |
 |* 18 |                   INDEX UNIQUE SCAN          | I_OBJ1           |
 | 19 |              TABLE ACCESS BY INDEX ROWID      | OBJ$             |
 |* 20 |               INDEX UNIQUE SCAN              | I_OBJ1           |
 | 21 |            TABLE ACCESS BY INDEX ROWID        | OBJ$             |
 |* 22 |             INDEX UNIQUE SCAN                | I_OBJ1           |
 | 23 |          TABLE ACCESS FULL                    | USER$            |
 | 24 |        TABLE ACCESS CLUSTER                   | SEG$             |
 |* 25 |         INDEX UNIQUE SCAN                    | I_FILE#_BLOCK# |
 | 26 |      NESTED LOOPS                             |                  |
 |* 27 |       INDEX RANGE SCAN                       | I_OBJAUTH1       |
 |* 28 |       FIXED TABLE FULL                       | X$KZSRO          |
 |* 29 |         FIXED TABLE FULL                     | X$KZSPR          |
 -------------------------------------------------------------------------

                                         http://www.tanelpoder.com
Cascading rowsources
• Rows quot;cascadequot; upwards to parent rowsources from children
 -------------------------------------------------------------------------
                                                           Execution plan
 | Id | Operation                                     | Name             |                      SELECT
                                                                                                          cursor
                                                             structure
 -------------------------------------------------------------------------                      processor
 |   0 | SELECT STATEMENT                             |                  |
                                                                                                                                    app.




                                                                                                   row source
 |* 1 |    FILTER                                     |                  |
 |   2|      NESTED LOOPS OUTER                       |                  |
 |* 3 |        HASH JOIN OUTER                        |                  |
 |   4|          NESTED LOOPS OUTER                   |                  |
 |   5|            NESTED LOOPS OUTER                 |                  |                      HASH
                                                                                                JOIN
 |* 6 |              HASH JOIN                        |                  |                e                       ro
                                                                                        rc                          w
                                                                                     ou
 |   7|                TABLE ACCESS FULL              | USER$            |                                              so
                                                                                   s                                      ur
                                                                                 w
 |   8|                NESTED LOOPS                   |                  |                                                     ce
                                                                              ro
 |* 9 |                  HASH JOIN                    |                  |
 | 10 |                    MERGE JOIN CARTESIAN       |                  | USER$                                                      NL
                                                                                                                                     JOIN
 |* 11 |                     HASH JOIN                |                  |
 |* 12 |                       FIXED TABLE FULL       | X$KSPPI          |                                                                  ro
                                                                                                                                    ce        w
                                                                                                                             ur
 | 13 |                        FIXED TABLE FULL       | X$KSPPCV         |                                                                        so
                                                                                                                           so                       ur
 | 14 |                      BUFFER SORT              |                  |                                                                               ce
                                                                                                                       w
                                                                                                                    ro
 | 15 |                        TABLE ACCESS FULL      | TS$              |
 |* 16 |                   TABLE ACCESS FULL          | TAB$             |                                                                               OBJ$
                                                                                                                HASH
 |* 17 |                 TABLE ACCESS BY INDEX ROWID | OBJ$              |                                      JOIN
 |* 18 |                   INDEX UNIQUE SCAN          | I_OBJ1           |
                                                                                                                               RS
                                                                                                   S
 | 19 |              TABLE ACCESS BY INDEX ROWID      | OBJ$             |                        R
 |* 20 |               INDEX UNIQUE SCAN              | I_OBJ1           |
                                                                                               MERGE
 | 21 |            TABLE ACCESS BY INDEX ROWID        | OBJ$             |                                                      TAB$
                                                                                               CART.
 |* 22 |             INDEX UNIQUE SCAN                | I_OBJ1           |                      JOIN
 | 23 |          TABLE ACCESS FULL                    | USER$            |                 S                      RS
                                                                                         R
 | 24 |        TABLE ACCESS CLUSTER                   | SEG$             |
 |* 25 |         INDEX UNIQUE SCAN                    | I_FILE#_BLOCK# |
                                                                                  HASH
 | 26 |      NESTED LOOPS                             |                  |         JOIN                                 TS$
 |* 27 |       INDEX RANGE SCAN                       | I_OBJAUTH1       |S                       RS
                                                                         |R
 |* 28 |       FIXED TABLE FULL                       | X$KZSRO
 |* 29 |         FIXED TABLE FULL                     | X$KZSPR          |
                                                                       X$KSPPI                 X$KSPPCV
 -------------------------------------------------------------------------

                                               http://www.tanelpoder.com
Row source execution
• At any point of time only one branch of exec. plan is executed
 -------------------------------------------------------------------------
                                                           Execution plan
 | Id | Operation                                     | Name             |                      SELECT
                                                                                                          cursor
                                                             structure
 -------------------------------------------------------------------------                      processor
 |   0 | SELECT STATEMENT                             |                  |
                                                                                                                                    app.




                                                                                                   row source
 |* 1 |    FILTER                                     |                  |
 |   2|      NESTED LOOPS OUTER                       |                  |
 |* 3 |        HASH JOIN OUTER                        |                  |
 |   4|          NESTED LOOPS OUTER                   |                  |
 |   5|            NESTED LOOPS OUTER                 |                  |                      HASH
                                                                                                JOIN
 |* 6 |              HASH JOIN                        |                  |                e                       ro
                                                                                        rc                          w
                                                                                     ou
 |   7|                TABLE ACCESS FULL              | USER$            |                                              so
                                                                                   s                                      ur
                                                                                 w
 |   8|                NESTED LOOPS                   |                  |                                                     ce
                                                                              ro
 |* 9 |                  HASH JOIN                    |                  |
 | 10 |                    MERGE JOIN CARTESIAN       |                  | USER$                                                      NL
                                                                                                                                     JOIN
 |* 11 |                     HASH JOIN                |                  |
 |* 12 |                       FIXED TABLE FULL       | X$KSPPI          |                                                                  ro
                                                                                                                                    ce        w
                                                                                                                             ur
 | 13 |                        FIXED TABLE FULL       | X$KSPPCV         |                                                                        so
                                                                                                                           so                       ur
 | 14 |                      BUFFER SORT              |                  |                                                                               ce
                                                                                                                       w
                                                                                                                    ro
 | 15 |                        TABLE ACCESS FULL      | TS$              |
 |* 16 |                   TABLE ACCESS FULL          | TAB$             |                                                                               OBJ$
                                                                                                                HASH
 |* 17 |                 TABLE ACCESS BY INDEX ROWID | OBJ$              |                                      JOIN
 |* 18 |                   INDEX UNIQUE SCAN          | I_OBJ1           |
                                                                                                                               RS
                                                                                                   S
 | 19 |              TABLE ACCESS BY INDEX ROWID      | OBJ$             |                        R
 |* 20 |               INDEX UNIQUE SCAN              | I_OBJ1           |
                                                                                               MERGE
 | 21 |            TABLE ACCESS BY INDEX ROWID        | OBJ$             |                                                      TAB$
                                                                                               CART.
 |* 22 |             INDEX UNIQUE SCAN                | I_OBJ1           |                      JOIN
 | 23 |          TABLE ACCESS FULL                    | USER$            |                 S                      RS
                                                                                         R
 | 24 |        TABLE ACCESS CLUSTER                   | SEG$             |
 |* 25 |         INDEX UNIQUE SCAN                    | I_FILE#_BLOCK# |
                                                                                  HASH
 | 26 |      NESTED LOOPS                             |                  |         JOIN                                 TS$
 |* 27 |       INDEX RANGE SCAN                       | I_OBJAUTH1       |S                       RS
                                                                         |R
 |* 28 |       FIXED TABLE FULL                       | X$KZSRO
 |* 29 |         FIXED TABLE FULL                     | X$KZSPR          |
                                                                       X$KSPPI                 X$KSPPCV
 -------------------------------------------------------------------------

                                               http://www.tanelpoder.com
Reading SQL plan execution stack
$ pstack 1354 | os_explain
   SELECT FETCH:
    SORT: Fetch
     HASH JOIN: Fetch
    * HASH JOIN: Fetch
     * VIEW: Fetch
        NESTED LOOP OUTER: Fetch
         NESTED LOOP OUTER: Fetch
          NESTED LOOP JOIN: Fetch
           HASH JOIN: Fetch
          * VIEW: Fetch
             UNION-ALL: Fetch
            * VIEW: Fetch
               UNION-ALL: Fetch
              * NESTED LOOP OUTER: Fetch
                 NESTED LOOP OUTER: Fetch
                  GRANULE ITERATOR: Fetch
                   INDEX: FetchFastFullScan
                    kdirfrs



Tanel Poder
Interpreting rowsource functions with os_explain
select /*+ ordered use_nl(b) use_nl(c) use_nl(d)
           full(a) full(b) full(c) full(d) */
count(*)
from    sys.obj$ a, sys.obj$ b, sys.obj$ c, sys.obj$ d
where
    a.owner# = b.owner# and b.owner# = c.owner#
and c.owner# = d.owner# and rownum <= 10000000000

------------------------------------------------ 1595 | ./os_explain
$ pstack 1595 | ./os_explain            $ pstack
| Id | Operation
   kpoal8                      | Name | E-Rows |
                                           kpoal8
------------------------------------------------
    SELECT FETCH:                           SELECT FETCH:
|   1GROUP BY SORT: Fetch
      | SORT AGGREGATE         |      |      GROUP BY SORT: Fetch
                                             1|
|* 2 COUNT: Fetch
      |   COUNT STOPKEY        |      |       COUNT: Fetch
                                               |
|   3 |NESTED LOOPLOOPS Fetch |
           NESTED JOIN:               |    361P|
                                               NESTED LOOP JOIN: Fetch
|   4 | TABLE ACCESS: Fetch
            NESTED LOOPS       |      |     19T|TABLE ACCESS: Fetch
|   5 | kdsttgr
             NESTED LOOPS      |      |   1011M| kdsttgr
|   6|    kdstf0100101km
              TABLE ACCESS FULL| OBJ$ | 53517 | kdstf0100101km
|* 7 |     kdst_fetch
              TABLE ACCESS FULL| OBJ$ | 18909 |       expeal
|* 8 |      ktrget ACCESS FULL | OBJ$ | 18909 |
             TABLE                                      expepr
|* 9 |      TABLE ACCESS FULL | OBJ$ | 18909 |
             kcbgtcr                                      evareo
                                             Child row source function
------------------------------------------------           lmebco
                                            must map directly to a child
                                                  line in exec plan
                          http://www.tanelpoder.com
Diagnosing PL/SQL execution
• V$SESSION new columns from 10.2.0.3
    PLSQL_ENTRY_OBJECT_ID
    PLSQL_ENTRY_SUBPROGRAM_ID
    PLSQL_OBJECT_ID
    PLSQL_SUBPROGRAM_ID


• Dump errorstack shows PL/SQL line number info:
  *** 2008-12-05 11:43:17.781
  ksedmp: internal or fatal error
  Current SQL statement for this session:
  BEGIN dbms_lock.sleep(100); END;
  ----- PL/SQL Call Stack -----
    object      line object
    handle    number name
                 201 package body SYS.DBMS_LOCK
  20496E0C
                   1 anonymous block
  204E46E8
Scripts for low-level Oracle diagnosis - demos
• dstackprof
        DTrace based stack profiler


• ostackprof
        oradebug short_stack based stack profiler


• latchprofx
        session level latch holder profiling script
        plain SQL!
        includes info in which function in Oracle kernel the latch
        get was invoked


Tanel Poder
What if my problem lies outside Oracle?




                  …Where to look next?




Tanel Poder
Oracle internal process flow
                                               Time
 APP      Application
 OCI      Oracle Call Interface
 UPI      User program interface
 Oracle
          SQL*Net, Two-Task Common
Net/TTC
OS/TCP    TCP/IP
  Net     Ethernet / WAN link

OS/TCP    TCP/IP
 Oracle
          SQL*Net, Two-Task Common
Net/TTC
                                                      Oracle Wait Interface
 OPI      Oracle Program Interface

                                                          V$SESSTAT
  kks     Kernel Kompile Shared (cursors)

  qer                                                         V$...
          Query Execution Runtime
  kcb     Kernel Cache Buffer management
  ksf     Kernel Service File i/o
 skgf     (OSD) System Kernel Generic File ?
  OS
          OS / IO system calls

Tanel Poder
Oracle internal process flow
 APP      Application                          Application instrumentation, ltrace, truss -uquot;libclntsh:*quot;
 OCI      Oracle Call Interface                $OH/rdbms/demo/ociucb.mk, OCITrace
 UPI      User program interface               -
 Oracle
          SQL*NET, TNS, Two-Task Common        SQL*Net trace, Wireshark TNS protocol digester
Net/TTC
OS/TCP    TCP/IP                               Wireshark TCP protocol digester, truss, strace
  Net     Ethernet / WAN link                  snoop, tcpdump, Wireshark
OS/TCP    TCP/IP                               Wireshark TCP protocol digester, truss, strace
 Oracle
          SQL*NET, TNS, Two-Task Common        SQL*Net trace, Wireshark, Event 10079
Net/TTC
 OPI      Oracle Program Interface             Event 10051
  kks     Kernel Kompile Shared (cursors)      sql_trace, Event 10046, 10270, cursortrace
  qer     Query Execution Runtime              v$sql_plan_statistics, v$sql_plan_statistics_all, sql_trace
  kcb     Kernel Cache Buffer management       x$kcbsw, Event 10200,10812, _trace_pin_time
  ksf     Kernel Service File i/o              v$filestat, v$tempstat, v$session_wait, Event 10298
 skgf     (OSD) System Kernel Generic File ?   -
  OS
          OS / IO system calls                 DTrace, strace, truss, tusc, filemon.exe, procmon.exe

Tanel Poder
Tanel Poder
Repeat: Session troubleshooting sequence


1. Oracle Wait Interface - response TIME!

                          ?
2. v$sesstat performance counters - hints, indicators
                          ?
3. Process stack - truth about process execution

                         !!!
Tanel Poder
Session-level troubleshooting tools
1. Profile session wait / CPU breakdown - TIME!
          V$SESSION_WAIT
          V$SESSION_EVENT, V$SESS_TIME_MODEL (10g+)
          Snapper, Sesspack, Statspack session mode


2. Profile session performance counters - occurrences
          V$SESSTAT



3. Profile session's process stack - statistical sample
          pstack, procstack, ostackprof, dstackprof
          procmon.exe, procexp.exe
          oradebug short_stack, oradebug errorstack


Tanel Poder
A slide to prove that I do use GUIs...
                          occasionally ;-)




Tanel Poder
References
• Metalink notes:
    459694.1 - Procwatcher: Script to Monitor and Examine Oracle and CRS
    Processes
    175982.1 - ORA-600 Lookup Error Categories (explains function names)


• Web:
    http://blog.tanelpoder.com
    http://www.juliandyke.com/Diagnostics/Diagnostics.html


• Seminar:
    If you like this stuff, you'll definitely like my seminar!
    http://blog.tanelpoder.com/seminar/
Questions?
Further questions welcome at
 http://blog.tanelpoder.com
Thank you!


        Tanel Põder
  tanel@tanelpoder.com
http://www.tanelpoder.com

Contenu connexe

Tendances

Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTanel Poder
 
Oracle Exadata Performance: Latest Improvements and Less Known Features
Oracle Exadata Performance: Latest Improvements and Less Known FeaturesOracle Exadata Performance: Latest Improvements and Less Known Features
Oracle Exadata Performance: Latest Improvements and Less Known FeaturesTanel Poder
 
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...Kristofferson A
 
Christo kutrovsky oracle, memory & linux
Christo kutrovsky   oracle, memory & linuxChristo kutrovsky   oracle, memory & linux
Christo kutrovsky oracle, memory & linuxKyle 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
 
Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)Tanel Poder
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersKyle Hailey
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder
 
Ukoug15 SIMD outside and inside Oracle 12c (12.1.0.2)
Ukoug15 SIMD outside and inside Oracle 12c (12.1.0.2)Ukoug15 SIMD outside and inside Oracle 12c (12.1.0.2)
Ukoug15 SIMD outside and inside Oracle 12c (12.1.0.2)Laurent Leturgez
 
vSphere vStorage: Troubleshooting Performance
vSphere vStorage: Troubleshooting PerformancevSphere vStorage: Troubleshooting Performance
vSphere vStorage: Troubleshooting PerformanceProfessionalVMware
 
Cloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And TricksCloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And TricksScott Jenner
 
Ehcache 3: JSR-107 on steroids at Devoxx Morocco
Ehcache 3: JSR-107 on steroids at Devoxx MoroccoEhcache 3: JSR-107 on steroids at Devoxx Morocco
Ehcache 3: JSR-107 on steroids at Devoxx MoroccoLouis Jacomet
 
Oaktable World 2014 Kevin Closson: SLOB – For More Than I/O!
Oaktable World 2014 Kevin Closson:  SLOB – For More Than I/O!Oaktable World 2014 Kevin Closson:  SLOB – For More Than I/O!
Oaktable World 2014 Kevin Closson: SLOB – For More Than I/O!Kyle Hailey
 
Oracle real application clusters system tests with demo
Oracle real application clusters system tests with demoOracle real application clusters system tests with demo
Oracle real application clusters system tests with demoAjith Narayanan
 
Caching reboot: javax.cache & Ehcache 3
Caching reboot: javax.cache & Ehcache 3Caching reboot: javax.cache & Ehcache 3
Caching reboot: javax.cache & Ehcache 3Louis Jacomet
 
AWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add upAWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add upJohn Beresniewicz
 

Tendances (20)

Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
 
Oracle Exadata Performance: Latest Improvements and Less Known Features
Oracle Exadata Performance: Latest Improvements and Less Known FeaturesOracle Exadata Performance: Latest Improvements and Less Known Features
Oracle Exadata Performance: Latest Improvements and Less Known Features
 
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
Hotsos 2011: Mining the AWR repository for Capacity Planning, Visualization, ...
 
Christo kutrovsky oracle, memory & linux
Christo kutrovsky   oracle, memory & linuxChristo kutrovsky   oracle, memory & linux
Christo kutrovsky oracle, memory & linux
 
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
 
Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)Tanel Poder Oracle Scripts and Tools (2010)
Tanel Poder Oracle Scripts and Tools (2010)
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
 
Intro to ASH
Intro to ASHIntro to ASH
Intro to ASH
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata Migrations
 
Ukoug15 SIMD outside and inside Oracle 12c (12.1.0.2)
Ukoug15 SIMD outside and inside Oracle 12c (12.1.0.2)Ukoug15 SIMD outside and inside Oracle 12c (12.1.0.2)
Ukoug15 SIMD outside and inside Oracle 12c (12.1.0.2)
 
vSphere vStorage: Troubleshooting Performance
vSphere vStorage: Troubleshooting PerformancevSphere vStorage: Troubleshooting Performance
vSphere vStorage: Troubleshooting Performance
 
Cloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And TricksCloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
Cloug Troubleshooting Oracle 11g Rac 101 Tips And Tricks
 
Ehcache 3: JSR-107 on steroids at Devoxx Morocco
Ehcache 3: JSR-107 on steroids at Devoxx MoroccoEhcache 3: JSR-107 on steroids at Devoxx Morocco
Ehcache 3: JSR-107 on steroids at Devoxx Morocco
 
Oaktable World 2014 Kevin Closson: SLOB – For More Than I/O!
Oaktable World 2014 Kevin Closson:  SLOB – For More Than I/O!Oaktable World 2014 Kevin Closson:  SLOB – For More Than I/O!
Oaktable World 2014 Kevin Closson: SLOB – For More Than I/O!
 
Oracle real application clusters system tests with demo
Oracle real application clusters system tests with demoOracle real application clusters system tests with demo
Oracle real application clusters system tests with demo
 
Using AWR/Statspack for Wait Analysis
Using AWR/Statspack for Wait AnalysisUsing AWR/Statspack for Wait Analysis
Using AWR/Statspack for Wait Analysis
 
Caching reboot: javax.cache & Ehcache 3
Caching reboot: javax.cache & Ehcache 3Caching reboot: javax.cache & Ehcache 3
Caching reboot: javax.cache & Ehcache 3
 
Oss4b - pxc introduction
Oss4b   - pxc introductionOss4b   - pxc introduction
Oss4b - pxc introduction
 
Long live to CMAN!
Long live to CMAN!Long live to CMAN!
Long live to CMAN!
 
AWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add upAWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add up
 

En vedette

Oracle database backup recovery step by step
Oracle database backup recovery step by stepOracle database backup recovery step by step
Oracle database backup recovery step by stepAakash Mehndiratta
 
Table partitioning in Oracle Database
Table partitioning in Oracle DatabaseTable partitioning in Oracle Database
Table partitioning in Oracle DatabaseAakash Mehndiratta
 
Step by Step Oracle11g out of-place upgrade from 11.2.0.3 to 11.2.0.4
Step by Step Oracle11g out of-place upgrade from 11.2.0.3 to 11.2.0.4Step by Step Oracle11g out of-place upgrade from 11.2.0.3 to 11.2.0.4
Step by Step Oracle11g out of-place upgrade from 11.2.0.3 to 11.2.0.4Jorge Batista
 
Linux Shell Scripting Craftsmanship
Linux Shell Scripting CraftsmanshipLinux Shell Scripting Craftsmanship
Linux Shell Scripting Craftsmanshipbokonen
 
Trouble shoot with linux syslog
Trouble shoot with linux syslogTrouble shoot with linux syslog
Trouble shoot with linux syslogashok191
 
UNIX - Class5 - Advance Shell Scripting-P2
UNIX - Class5 - Advance Shell Scripting-P2UNIX - Class5 - Advance Shell Scripting-P2
UNIX - Class5 - Advance Shell Scripting-P2Nihar Ranjan Paital
 
UNIX - Class4 - Advance Shell Scripting-P1
UNIX - Class4 - Advance Shell Scripting-P1UNIX - Class4 - Advance Shell Scripting-P1
UNIX - Class4 - Advance Shell Scripting-P1Nihar Ranjan Paital
 
Karkha unix shell scritping
Karkha unix shell scritpingKarkha unix shell scritping
Karkha unix shell scritpingchockit88
 
Module 13 - Troubleshooting
Module 13 - TroubleshootingModule 13 - Troubleshooting
Module 13 - TroubleshootingT. J. Saotome
 
Oracle backup and recovery
Oracle backup and recoveryOracle backup and recovery
Oracle backup and recoveryYogiji Creations
 
Linux troubleshooting tips
Linux troubleshooting tipsLinux troubleshooting tips
Linux troubleshooting tipsBert Van Vreckem
 
unix training | unix training videos | unix course unix online training
unix training |  unix training videos |  unix course  unix online training unix training |  unix training videos |  unix course  unix online training
unix training | unix training videos | unix course unix online training Nancy Thomas
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingDan Morrill
 
25 Apache Performance Tips
25 Apache Performance Tips25 Apache Performance Tips
25 Apache Performance TipsMonitis_Inc
 
Fusion Middleware 11g How To Part 2
Fusion Middleware 11g How To Part 2Fusion Middleware 11g How To Part 2
Fusion Middleware 11g How To Part 2Dirk Nachbar
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshootingNathan Winters
 

En vedette (20)

Oracle database backup recovery step by step
Oracle database backup recovery step by stepOracle database backup recovery step by step
Oracle database backup recovery step by step
 
Table partitioning in Oracle Database
Table partitioning in Oracle DatabaseTable partitioning in Oracle Database
Table partitioning in Oracle Database
 
Step by Step Oracle11g out of-place upgrade from 11.2.0.3 to 11.2.0.4
Step by Step Oracle11g out of-place upgrade from 11.2.0.3 to 11.2.0.4Step by Step Oracle11g out of-place upgrade from 11.2.0.3 to 11.2.0.4
Step by Step Oracle11g out of-place upgrade from 11.2.0.3 to 11.2.0.4
 
Linux Shell Scripting Craftsmanship
Linux Shell Scripting CraftsmanshipLinux Shell Scripting Craftsmanship
Linux Shell Scripting Craftsmanship
 
Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02Unixshellscript 100406085942-phpapp02
Unixshellscript 100406085942-phpapp02
 
Trouble shoot with linux syslog
Trouble shoot with linux syslogTrouble shoot with linux syslog
Trouble shoot with linux syslog
 
UNIX - Class1 - Basic Shell
UNIX - Class1 - Basic ShellUNIX - Class1 - Basic Shell
UNIX - Class1 - Basic Shell
 
UNIX - Class5 - Advance Shell Scripting-P2
UNIX - Class5 - Advance Shell Scripting-P2UNIX - Class5 - Advance Shell Scripting-P2
UNIX - Class5 - Advance Shell Scripting-P2
 
UNIX - Class4 - Advance Shell Scripting-P1
UNIX - Class4 - Advance Shell Scripting-P1UNIX - Class4 - Advance Shell Scripting-P1
UNIX - Class4 - Advance Shell Scripting-P1
 
Karkha unix shell scritping
Karkha unix shell scritpingKarkha unix shell scritping
Karkha unix shell scritping
 
Module 13 - Troubleshooting
Module 13 - TroubleshootingModule 13 - Troubleshooting
Module 13 - Troubleshooting
 
APACHE
APACHEAPACHE
APACHE
 
Oracle backup and recovery
Oracle backup and recoveryOracle backup and recovery
Oracle backup and recovery
 
Linux troubleshooting tips
Linux troubleshooting tipsLinux troubleshooting tips
Linux troubleshooting tips
 
unix training | unix training videos | unix course unix online training
unix training |  unix training videos |  unix course  unix online training unix training |  unix training videos |  unix course  unix online training
unix training | unix training videos | unix course unix online training
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
 
25 Apache Performance Tips
25 Apache Performance Tips25 Apache Performance Tips
25 Apache Performance Tips
 
Fusion Middleware 11g How To Part 2
Fusion Middleware 11g How To Part 2Fusion Middleware 11g How To Part 2
Fusion Middleware 11g How To Part 2
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshooting
 
Tomcat next
Tomcat nextTomcat next
Tomcat next
 

Similaire à Advanced Oracle Troubleshooting

How Prometheus Store the Data
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the DataHao Chen
 
OOW09 Ebs Tuning Final
OOW09 Ebs Tuning FinalOOW09 Ebs Tuning Final
OOW09 Ebs Tuning Finaljucaab
 
Linux Power Management Slideshare
Linux Power Management SlideshareLinux Power Management Slideshare
Linux Power Management SlidesharePatrick Bellasi
 
Galera Multi Master Synchronous My S Q L Replication Clusters
Galera  Multi Master  Synchronous  My S Q L  Replication  ClustersGalera  Multi Master  Synchronous  My S Q L  Replication  Clusters
Galera Multi Master Synchronous My S Q L Replication ClustersPerconaPerformance
 
Driver Debugging Basics
Driver Debugging BasicsDriver Debugging Basics
Driver Debugging BasicsBala Subra
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuningOutsourceAX
 
UML profiles for Embedded Systems
UML profiles for Embedded SystemsUML profiles for Embedded Systems
UML profiles for Embedded Systemspboulet
 
Debugging Tools & Techniques for Persistent Memory Programming
Debugging Tools & Techniques for Persistent Memory ProgrammingDebugging Tools & Techniques for Persistent Memory Programming
Debugging Tools & Techniques for Persistent Memory ProgrammingIntel® Software
 
SnappyData at Spark Summit 2017
SnappyData at Spark Summit 2017SnappyData at Spark Summit 2017
SnappyData at Spark Summit 2017Jags Ramnarayan
 
SnappyData, the Spark Database. A unified cluster for streaming, transactions...
SnappyData, the Spark Database. A unified cluster for streaming, transactions...SnappyData, the Spark Database. A unified cluster for streaming, transactions...
SnappyData, the Spark Database. A unified cluster for streaming, transactions...SnappyData
 
Reactive Summit 2017 Highlights!
Reactive Summit 2017 Highlights!Reactive Summit 2017 Highlights!
Reactive Summit 2017 Highlights!Fabio Tiriticco
 
Live traffic capture and replay in cassandra 4.0
Live traffic capture and replay in cassandra 4.0Live traffic capture and replay in cassandra 4.0
Live traffic capture and replay in cassandra 4.0Vinay Kumar Chella
 
Resume_CQ_Edward
Resume_CQ_EdwardResume_CQ_Edward
Resume_CQ_Edwardcaiqi wang
 
JVM Tuning and Profiling
JVM Tuning and ProfilingJVM Tuning and Profiling
JVM Tuning and ProfilingBhuvan Rawal
 

Similaire à Advanced Oracle Troubleshooting (20)

How Prometheus Store the Data
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the Data
 
OOW09 Ebs Tuning Final
OOW09 Ebs Tuning FinalOOW09 Ebs Tuning Final
OOW09 Ebs Tuning Final
 
Linux Power Management Slideshare
Linux Power Management SlideshareLinux Power Management Slideshare
Linux Power Management Slideshare
 
Galera Multi Master Synchronous My S Q L Replication Clusters
Galera  Multi Master  Synchronous  My S Q L  Replication  ClustersGalera  Multi Master  Synchronous  My S Q L  Replication  Clusters
Galera Multi Master Synchronous My S Q L Replication Clusters
 
Driver Debugging Basics
Driver Debugging BasicsDriver Debugging Basics
Driver Debugging Basics
 
Oracle analysis 101_v1.0_ext
Oracle analysis 101_v1.0_extOracle analysis 101_v1.0_ext
Oracle analysis 101_v1.0_ext
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuning
 
Triggers and Stored Procedures
Triggers and Stored ProceduresTriggers and Stored Procedures
Triggers and Stored Procedures
 
UML profiles for Embedded Systems
UML profiles for Embedded SystemsUML profiles for Embedded Systems
UML profiles for Embedded Systems
 
Debugging Tools & Techniques for Persistent Memory Programming
Debugging Tools & Techniques for Persistent Memory ProgrammingDebugging Tools & Techniques for Persistent Memory Programming
Debugging Tools & Techniques for Persistent Memory Programming
 
Using AWR for SQL Analysis
Using AWR for SQL AnalysisUsing AWR for SQL Analysis
Using AWR for SQL Analysis
 
SnappyData at Spark Summit 2017
SnappyData at Spark Summit 2017SnappyData at Spark Summit 2017
SnappyData at Spark Summit 2017
 
SnappyData, the Spark Database. A unified cluster for streaming, transactions...
SnappyData, the Spark Database. A unified cluster for streaming, transactions...SnappyData, the Spark Database. A unified cluster for streaming, transactions...
SnappyData, the Spark Database. A unified cluster for streaming, transactions...
 
Ashawr perf kscope
Ashawr perf kscopeAshawr perf kscope
Ashawr perf kscope
 
Percona toolkit
Percona toolkitPercona toolkit
Percona toolkit
 
Reactive Summit 2017 Highlights!
Reactive Summit 2017 Highlights!Reactive Summit 2017 Highlights!
Reactive Summit 2017 Highlights!
 
Live traffic capture and replay in cassandra 4.0
Live traffic capture and replay in cassandra 4.0Live traffic capture and replay in cassandra 4.0
Live traffic capture and replay in cassandra 4.0
 
Sql optimize
Sql optimizeSql optimize
Sql optimize
 
Resume_CQ_Edward
Resume_CQ_EdwardResume_CQ_Edward
Resume_CQ_Edward
 
JVM Tuning and Profiling
JVM Tuning and ProfilingJVM Tuning and Profiling
JVM Tuning and Profiling
 

Plus de Hector Martinez

Administración de Oracle - Tema 4 - Interacción con la Base de Datos
Administración de Oracle - Tema 4 - Interacción con la Base de DatosAdministración de Oracle - Tema 4 - Interacción con la Base de Datos
Administración de Oracle - Tema 4 - Interacción con la Base de DatosHector Martinez
 
Escalado y Replicación en MySQL
Escalado y Replicación en MySQLEscalado y Replicación en MySQL
Escalado y Replicación en MySQLHector Martinez
 
Oracle Upgrade11gr1 Workshop1
Oracle Upgrade11gr1 Workshop1Oracle Upgrade11gr1 Workshop1
Oracle Upgrade11gr1 Workshop1Hector Martinez
 
Administración de Oracle - Tema 3 - Creación de la BD
Administración de Oracle - Tema 3 - Creación de la BDAdministración de Oracle - Tema 3 - Creación de la BD
Administración de Oracle - Tema 3 - Creación de la BDHector Martinez
 
Administración de Oracle - Tema 02 - Instalación
Administración de Oracle - Tema 02 - InstalaciónAdministración de Oracle - Tema 02 - Instalación
Administración de Oracle - Tema 02 - InstalaciónHector Martinez
 
Administración de Oracle - Tema 01 - Introducción
Administración de Oracle - Tema 01 - IntroducciónAdministración de Oracle - Tema 01 - Introducción
Administración de Oracle - Tema 01 - IntroducciónHector Martinez
 

Plus de Hector Martinez (6)

Administración de Oracle - Tema 4 - Interacción con la Base de Datos
Administración de Oracle - Tema 4 - Interacción con la Base de DatosAdministración de Oracle - Tema 4 - Interacción con la Base de Datos
Administración de Oracle - Tema 4 - Interacción con la Base de Datos
 
Escalado y Replicación en MySQL
Escalado y Replicación en MySQLEscalado y Replicación en MySQL
Escalado y Replicación en MySQL
 
Oracle Upgrade11gr1 Workshop1
Oracle Upgrade11gr1 Workshop1Oracle Upgrade11gr1 Workshop1
Oracle Upgrade11gr1 Workshop1
 
Administración de Oracle - Tema 3 - Creación de la BD
Administración de Oracle - Tema 3 - Creación de la BDAdministración de Oracle - Tema 3 - Creación de la BD
Administración de Oracle - Tema 3 - Creación de la BD
 
Administración de Oracle - Tema 02 - Instalación
Administración de Oracle - Tema 02 - InstalaciónAdministración de Oracle - Tema 02 - Instalación
Administración de Oracle - Tema 02 - Instalación
 
Administración de Oracle - Tema 01 - Introducción
Administración de Oracle - Tema 01 - IntroducciónAdministración de Oracle - Tema 01 - Introducción
Administración de Oracle - Tema 01 - Introducción
 

Dernier

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Dernier (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

Advanced Oracle Troubleshooting

  • 1. Advanced Oracle Troubleshooting No magic is needed, systematic approach will do Tanel Põder http://www.tanelpoder.com
  • 2. Introduction • About me: Occupation: DBA, researcher, consultant Expertise: Oracle internals geek, End-to-end performance & scalability, troubleshooting Oracle experience: 12+ years as DBA Certification: OCM (2002) OCP (1999) Professional affiliations: OakTable Network Blog: http://blog.tanelpoder.com Seminar: http://blog.tanelpoder.com/seminar/ Tanel Poder
  • 3. Introduction • About this presentation: Systematic approach, rather than methodology Use right tools for right problems Break complex problems down to simple problems Therefore, use simple tools for simple problems In other words, use a systematic approach and life will be easier! • Less slides, more action! • All scripts used here are freely available: http://www.tanelpoder.com Tanel Poder
  • 4. Metalink forum thread example: Query is taking long time to complete--Need urgent help From: …………… 05-Jun-08 08:40 Subject: Re : Query is taking long time to complete--Need urgent help Posting TKPROF may help. -------------------------------------------------------------------------------- From: …………… 05-Jun-08 21:33 Subject: Re : Query is taking long time to complete--Need urgent help Just a hunch, but try changing optimizer mode to FIRST_ROWS. -------------------------------------------------------------------------------- From: …………… 06-Jun-08 03:08 Subject: Re : Query is taking long time to complete--Need urgent help Hi, Please try using the HINTS like FIRST_ROWS or USE_HASH. This may solve the problem. © 2008 Tanel Poder http://www.tanelpoder.com 4
  • 5. Simple (but common) question: What the $#*&%! is that session doing? Tanel Poder
  • 6. Non-systematic troubleshooting • Check alert.log… • Check for disk and tablespace free space… • Check for locks… • Check for xyz… quot;We did a healthcheck and everything looks OK!quot; ?????! Tanel Poder
  • 7. Semi-systematic troubleshooting • Quick check for usual suspects System load, locks, etc… • Look into Statspack (or AWR)… • Enable sql_trace… …then what? Tanel Poder
  • 8. Systematic troubleshooting Demo Tanel Poder
  • 9. Troubleshooting approaches • How do you solve problems? a) Change Problem Did it help? something fixed ? b) Understand Problem Manage fixed and Sure? change prevented Measure Tanel Poder
  • 10. Non-Systematic approach! Users Users Users Users Users Users Users Users locks Statspack v$latch disk space ? vmstat alert.log free memory optimizer statistics Tanel Poder
  • 11. Systematic approach! User X Users Users Users Users Users Users Users Users Users Session V$SESSION_WAIT, V$SESSION_EVENT, V$SESSTAT SID Server process stack sampling SPID process Tanel Poder
  • 12. Systematic troubleshooting • Understand the quot;flowquot; of a server process • …and how to measure it • …then measure it • …step by step • …using right tool at right step • ...fix the problem once you understand it Tanel Poder
  • 13. Right tools for measuring right problems Detail level sw.sql / se.sql Entry point Wait / CPU snapper.sql profile Sesspack sample u.sql Cursor v$session.sql_id sql.sql execution sql_hash_value sqlt.sql profile PL/SQL code snapper.sql Performance dbms_profiler execution Sesspack counter profile profile xms.sql SQL Kernel function stack sampling xmsh.sql rowsource execution pstack dbms_xplan execution profile “allstats last” profile Tanel Poder
  • 14. sw.sql and Snapper demo SQL> @sw 114 SID STATE EVENT SEQ# SEC_IN_WAIT P1 P2 P3 P1TRANSL ------- ------- ---------------------------------------- ---------- ----------- ---------- ---------- ---------- ---------------------- 114 WAITING enq: TX - row lock contention 21 9 1415053318 131081 2381 0x54580006: TX mode 6 SQL> @sw &mysid SID STATE EVENT SEQ# SEC_IN_WAIT P1 P2 P3 P1TRANSL ------- ------- ---------------------------------------- ---------- ----------- ---------- ---------- ---------- ---------------------- 107 WORKING On CPU / runqueue 89 0 1413697536 1 0 SQL> SQL> @sn 5 &mysid -- Session Snapper v1.06 by Tanel Poder ( http://www.tanelpoder.com ) --------------------------------------------------------------------------------------------------------------------------------------------- HEAD, SID, SNAPSHOT START , SECONDS, TYPE, STATISTIC , DELTA, DELTA/SEC, HDELTA, HDELTA/SEC --------------------------------------------------------------------------------------------------------------------------------------------- DATA, 9, 20080221 22:05:08, 5, STAT, recursive calls , 1, 0, 1, .2 DATA, 9, 20080221 22:05:08, 5, STAT, recursive cpu usage , 1, 0, 1, .2 DATA, 9, 20080221 22:05:08, 5, STAT, session pga memory max , 25292, 5058, 25.29k, 5.06k DATA, 9, 20080221 22:05:08, 5, STAT, calls to get snapshot scn: kcmgss , 1, 0, 1, .2 DATA, 9, 20080221 22:05:08, 5, STAT, workarea executions - optimal , 18, 4, 18, 3.6 DATA, 9, 20080221 22:05:08, 5, STAT, execute count , 1, 0, 1, .2 DATA, 9, 20080221 22:05:08, 5, STAT, sorts (memory) , 11, 2, 11, 2.2 DATA, 9, 20080221 22:05:08, 5, STAT, sorts (rows) , 1904, 381, 1.9k, 380.8 DATA, 9, 20080221 22:05:08, 5, WAIT, PL/SQL lock timer , 4999649, 999930, 5s, 999.93ms -- End of snap 1 PL/SQL procedure successfully completed. Tanel Poder
  • 15. If this doesn't help… …Where to look next? Tanel Poder
  • 16. Session troubleshooting sequence 1. Oracle Wait Interface - response TIME! ? 2. v$sesstat performance counters - hints, indicators ? 3. Process stack - truth about process execution !!! Tanel Poder
  • 17. Process stack demos $ pstack 5855 #0 0x00c29402 in __kernel_vsyscall () #1 0x005509e4 in semtimedop () from /lib/libc.so.6 #2 0x0e5769b7 in sskgpwwait () #3 0x0e575946 in skgpwwait () #4 0x0e2c3adc in ksliwat () Where to look up the meaning of Oracle kernel #5 0x0e2c3449 in kslwaitctx. () function names? #6 0x0b007261 in kjusuc () #7 0x0c8a7961 in ksipgetctx () #8 0x0e2d4dec in ksqcmi () #9 0x0e2ce9b8 in ksqgtlctx () 1) Metalink: #10 0x0e2cd214 in ksqgelctx. () #11 0x08754afa in ktcwit1 () 175982.1 ORA-600 Lookup Error Categories #12 0x0e39b2a8 in kdddgb () #13 0x08930c80 in kdddel () 453521.1 ORA-04031 “KSFQ Buffers” ksmlgpalloc #14 0x0892af0f in kaudel () #15 0x08c3d21a in delrow () Search: <function> quot;executable entry point” #16 0x08e6ce16 in qerdlFetch () #17 0x08c403c5 in delexe () 2) Oracle views #18 0x0e3c3fa9 in opiexe () #19 0x08b54500 in kpoal8 () v$latch_misses (lm.sql) #20 0x0e3be673 in opiodr () #21 0x0e53628a in ttcpip () v$latchholder (latchprofx.sql) #22 0x089a87ab in opitsk () #23 0x089aaa00 in opiino () v$fixed_view_definition (d.sql, f.sql) #24 0x0e3be673 in opiodr () #25 0x089a4e76 in opidrv () 3) Internet search #26 0x08c1626f in sou2o () #27 0x08539aeb in opimai_real () #28 0x08c19a42 in ssthrdmain () #29 0x08539a68 in main () Tanel Poder
  • 18. Getting stack traces • OS stack dumper pstack - Solaris, Linux, HP-UX procstack - AIX gdb bt, mdb $c Procwatcher (Metalink note: 459694.1) • Windows windbg, procexp - but no symbolic function names in oracle.exe :( • Oracle internal oradebug short_stack oradebug dump errorstack 1 alter session set events '942 trace name errorstack' Tanel Poder
  • 19. Troubleshooting SQL plan execution ...first requires understanding how SQL is executed!
  • 20. What is an execution plan? • For Oracle server: Parsed, optimized and compiled SQL code kept inside library cache • For DBAs and developers: Text or graphical representation of SQL execution flow • Often known as explain plan To be correct in terms, explain plan is just a tool, command in Oracle Explain plan outputs textual representation of execution plan into plan table DBAs/developers report human readable output from plan table
  • 21. One slide for getting execution plan • Starting from 9.2 the recommended way is: explain plan for <statement> select * from table(dbms_xplan.display) • In 10g the autotrace also uses dbms_xplan set autotrace on or select * from table(dbms_xplan.display_cursor()) • In 11g DBMS_SQLTUNE.REPORT_SQL_MONITOR • Other methods sql_trace / event 10046 trace + tkprof utility v$sql_plan setting event 10132 at level 1 3rd party tools (which use explain plan anyway)
  • 22. Parse stages • Syntactic check Syntax, keywords, sanity soft parse • Semantic check Whether objects referenced exist, are accessible (by permissions) and are usable • View merging Queries are written to reference base tables Can merge both stored views and inline views hard parse • Query transformation Transitivity, etc (example: if a=1 and a=b then b=1) • Optimization • Query execution plan (QEP) generation • Loading SQL and execution plan in library cache
  • 23. SQL execution data flow - basics ------------------------------------------ Execution plan | Id | Operation | Name | ------------------------------------------ SELECT | 0 | SELECT STATEMENT | | cursor |* 1 | HASH JOIN | | processor |* 2 | TABLE ACCESS FULL| DEPARTMENTS | |* 3 | TABLE ACCESS FULL| EMPLOYEES | application ------------------------------------------ row source SELECT Query E.LAST_NAME, D.DEPARTMENT_NAME FROM EMPLOYEES E, DEPARTMENTS D WHERE E.DEPARTMENT_ID = HASH JOIN D.DEPARTMENT_ID FI LT AND D.DEPARTMENT_NAME = ER ta ER 'Sales' bl LT e AND E.SALARY > 2000; r o ac e FI rc w ce an u so so s s sc ur fu e w bl ce l l ro ta DEPARTMENTS EMPLOYEES http://www.tanelpoder.com
  • 24. SQL execution data flow - multitable joins SELECT Multiple joins E.LAST_NAME, D.DEPARTMENT_NAME, SELECT cursor L.CITY processor FROM app. EMPLOYEES E, row source DEPARTMENTS D, LOCATIONS L WHERE E.DEPARTMENT_ID = D.DEPARTMENT_ID AND D.DEPARTMENT_NAME = 'Sales' AND D.LOCATION_ID = L.LOCATION_IID AND E.SALARY > 2000; HASH JOIN ro e w rc so u Only two row sources can be so u rc w joined together at a time e ro Row sources pass their data EMPLOYEES quot;upquot; the execution plan tree NL JOIN The join order is determined during optimization phase ro e w rc so u so u rc w e ro DEPARTMENTS LOCATIONS http://www.tanelpoder.com
  • 25. Reading execution plans: Rule 1 • Parent operations get input only from their children ------------------------------------------------------------------------- Execution plan | Id | Operation | Name | structure ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | |* 1 | FILTER | | | 2| NESTED LOOPS OUTER | | |* 3 | HASH JOIN OUTER | | | 4| NESTED LOOPS OUTER | | | 5| NESTED LOOPS OUTER | | |* 6 | HASH JOIN | | | 7| TABLE ACCESS FULL | USER$ | | 8| NESTED LOOPS | | |* 9 | HASH JOIN | | | 10 | MERGE JOIN CARTESIAN | | |* 11 | HASH JOIN | | |* 12 | FIXED TABLE FULL | X$KSPPI | | 13 | FIXED TABLE FULL | X$KSPPCV | | 14 | BUFFER SORT | | | 15 | TABLE ACCESS FULL | TS$ | |* 16 | TABLE ACCESS FULL | TAB$ | |* 17 | TABLE ACCESS BY INDEX ROWID | OBJ$ | |* 18 | INDEX UNIQUE SCAN | I_OBJ1 | | 19 | TABLE ACCESS BY INDEX ROWID | OBJ$ | |* 20 | INDEX UNIQUE SCAN | I_OBJ1 | | 21 | TABLE ACCESS BY INDEX ROWID | OBJ$ | |* 22 | INDEX UNIQUE SCAN | I_OBJ1 | | 23 | TABLE ACCESS FULL | USER$ | | 24 | TABLE ACCESS CLUSTER | SEG$ | |* 25 | INDEX UNIQUE SCAN | I_FILE#_BLOCK# | | 26 | NESTED LOOPS | | |* 27 | INDEX RANGE SCAN | I_OBJAUTH1 | |* 28 | FIXED TABLE FULL | X$KZSRO | |* 29 | FIXED TABLE FULL | X$KZSPR | ------------------------------------------------------------------------- http://www.tanelpoder.com
  • 26. Reading execution plans: Rule 2 • Data access starts from the first line without children ------------------------------------------------------------------------- Execution plan | Id | Operation | Name | structure ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | |* 1 | FILTER | | | 2| NESTED LOOPS OUTER | | |* 3 | HASH JOIN OUTER | | | 4| NESTED LOOPS OUTER | | | 5| NESTED LOOPS OUTER | | |* 6 | HASH JOIN | | | 7| TABLE ACCESS FULL | USER$ | First operation with no children | 8| NESTED LOOPS | | (leaf operation) accesses data |* 9 | HASH JOIN | | | 10 | MERGE JOIN CARTESIAN | | |* 11 | HASH JOIN | | |* 12 | FIXED TABLE FULL | X$KSPPI | | 13 | FIXED TABLE FULL | X$KSPPCV | | 14 | BUFFER SORT | | | 15 | TABLE ACCESS FULL | TS$ | |* 16 | TABLE ACCESS FULL | TAB$ | |* 17 | TABLE ACCESS BY INDEX ROWID | OBJ$ | |* 18 | INDEX UNIQUE SCAN | I_OBJ1 | | 19 | TABLE ACCESS BY INDEX ROWID | OBJ$ | |* 20 | INDEX UNIQUE SCAN | I_OBJ1 | | 21 | TABLE ACCESS BY INDEX ROWID | OBJ$ | |* 22 | INDEX UNIQUE SCAN | I_OBJ1 | | 23 | TABLE ACCESS FULL | USER$ | | 24 | TABLE ACCESS CLUSTER | SEG$ | |* 25 | INDEX UNIQUE SCAN | I_FILE#_BLOCK# | | 26 | NESTED LOOPS | | |* 27 | INDEX RANGE SCAN | I_OBJAUTH1 | |* 28 | FIXED TABLE FULL | X$KZSRO | |* 29 | FIXED TABLE FULL | X$KZSPR | ------------------------------------------------------------------------- http://www.tanelpoder.com
  • 27. Cascading rowsources • Rows quot;cascadequot; upwards to parent rowsources from children ------------------------------------------------------------------------- Execution plan | Id | Operation | Name | SELECT cursor structure ------------------------------------------------------------------------- processor | 0 | SELECT STATEMENT | | app. row source |* 1 | FILTER | | | 2| NESTED LOOPS OUTER | | |* 3 | HASH JOIN OUTER | | | 4| NESTED LOOPS OUTER | | | 5| NESTED LOOPS OUTER | | HASH JOIN |* 6 | HASH JOIN | | e ro rc w ou | 7| TABLE ACCESS FULL | USER$ | so s ur w | 8| NESTED LOOPS | | ce ro |* 9 | HASH JOIN | | | 10 | MERGE JOIN CARTESIAN | | USER$ NL JOIN |* 11 | HASH JOIN | | |* 12 | FIXED TABLE FULL | X$KSPPI | ro ce w ur | 13 | FIXED TABLE FULL | X$KSPPCV | so so ur | 14 | BUFFER SORT | | ce w ro | 15 | TABLE ACCESS FULL | TS$ | |* 16 | TABLE ACCESS FULL | TAB$ | OBJ$ HASH |* 17 | TABLE ACCESS BY INDEX ROWID | OBJ$ | JOIN |* 18 | INDEX UNIQUE SCAN | I_OBJ1 | RS S | 19 | TABLE ACCESS BY INDEX ROWID | OBJ$ | R |* 20 | INDEX UNIQUE SCAN | I_OBJ1 | MERGE | 21 | TABLE ACCESS BY INDEX ROWID | OBJ$ | TAB$ CART. |* 22 | INDEX UNIQUE SCAN | I_OBJ1 | JOIN | 23 | TABLE ACCESS FULL | USER$ | S RS R | 24 | TABLE ACCESS CLUSTER | SEG$ | |* 25 | INDEX UNIQUE SCAN | I_FILE#_BLOCK# | HASH | 26 | NESTED LOOPS | | JOIN TS$ |* 27 | INDEX RANGE SCAN | I_OBJAUTH1 |S RS |R |* 28 | FIXED TABLE FULL | X$KZSRO |* 29 | FIXED TABLE FULL | X$KZSPR | X$KSPPI X$KSPPCV ------------------------------------------------------------------------- http://www.tanelpoder.com
  • 28. Row source execution • At any point of time only one branch of exec. plan is executed ------------------------------------------------------------------------- Execution plan | Id | Operation | Name | SELECT cursor structure ------------------------------------------------------------------------- processor | 0 | SELECT STATEMENT | | app. row source |* 1 | FILTER | | | 2| NESTED LOOPS OUTER | | |* 3 | HASH JOIN OUTER | | | 4| NESTED LOOPS OUTER | | | 5| NESTED LOOPS OUTER | | HASH JOIN |* 6 | HASH JOIN | | e ro rc w ou | 7| TABLE ACCESS FULL | USER$ | so s ur w | 8| NESTED LOOPS | | ce ro |* 9 | HASH JOIN | | | 10 | MERGE JOIN CARTESIAN | | USER$ NL JOIN |* 11 | HASH JOIN | | |* 12 | FIXED TABLE FULL | X$KSPPI | ro ce w ur | 13 | FIXED TABLE FULL | X$KSPPCV | so so ur | 14 | BUFFER SORT | | ce w ro | 15 | TABLE ACCESS FULL | TS$ | |* 16 | TABLE ACCESS FULL | TAB$ | OBJ$ HASH |* 17 | TABLE ACCESS BY INDEX ROWID | OBJ$ | JOIN |* 18 | INDEX UNIQUE SCAN | I_OBJ1 | RS S | 19 | TABLE ACCESS BY INDEX ROWID | OBJ$ | R |* 20 | INDEX UNIQUE SCAN | I_OBJ1 | MERGE | 21 | TABLE ACCESS BY INDEX ROWID | OBJ$ | TAB$ CART. |* 22 | INDEX UNIQUE SCAN | I_OBJ1 | JOIN | 23 | TABLE ACCESS FULL | USER$ | S RS R | 24 | TABLE ACCESS CLUSTER | SEG$ | |* 25 | INDEX UNIQUE SCAN | I_FILE#_BLOCK# | HASH | 26 | NESTED LOOPS | | JOIN TS$ |* 27 | INDEX RANGE SCAN | I_OBJAUTH1 |S RS |R |* 28 | FIXED TABLE FULL | X$KZSRO |* 29 | FIXED TABLE FULL | X$KZSPR | X$KSPPI X$KSPPCV ------------------------------------------------------------------------- http://www.tanelpoder.com
  • 29. Reading SQL plan execution stack $ pstack 1354 | os_explain SELECT FETCH: SORT: Fetch HASH JOIN: Fetch * HASH JOIN: Fetch * VIEW: Fetch NESTED LOOP OUTER: Fetch NESTED LOOP OUTER: Fetch NESTED LOOP JOIN: Fetch HASH JOIN: Fetch * VIEW: Fetch UNION-ALL: Fetch * VIEW: Fetch UNION-ALL: Fetch * NESTED LOOP OUTER: Fetch NESTED LOOP OUTER: Fetch GRANULE ITERATOR: Fetch INDEX: FetchFastFullScan kdirfrs Tanel Poder
  • 30. Interpreting rowsource functions with os_explain select /*+ ordered use_nl(b) use_nl(c) use_nl(d) full(a) full(b) full(c) full(d) */ count(*) from sys.obj$ a, sys.obj$ b, sys.obj$ c, sys.obj$ d where a.owner# = b.owner# and b.owner# = c.owner# and c.owner# = d.owner# and rownum <= 10000000000 ------------------------------------------------ 1595 | ./os_explain $ pstack 1595 | ./os_explain $ pstack | Id | Operation kpoal8 | Name | E-Rows | kpoal8 ------------------------------------------------ SELECT FETCH: SELECT FETCH: | 1GROUP BY SORT: Fetch | SORT AGGREGATE | | GROUP BY SORT: Fetch 1| |* 2 COUNT: Fetch | COUNT STOPKEY | | COUNT: Fetch | | 3 |NESTED LOOPLOOPS Fetch | NESTED JOIN: | 361P| NESTED LOOP JOIN: Fetch | 4 | TABLE ACCESS: Fetch NESTED LOOPS | | 19T|TABLE ACCESS: Fetch | 5 | kdsttgr NESTED LOOPS | | 1011M| kdsttgr | 6| kdstf0100101km TABLE ACCESS FULL| OBJ$ | 53517 | kdstf0100101km |* 7 | kdst_fetch TABLE ACCESS FULL| OBJ$ | 18909 | expeal |* 8 | ktrget ACCESS FULL | OBJ$ | 18909 | TABLE expepr |* 9 | TABLE ACCESS FULL | OBJ$ | 18909 | kcbgtcr evareo Child row source function ------------------------------------------------ lmebco must map directly to a child line in exec plan http://www.tanelpoder.com
  • 31. Diagnosing PL/SQL execution • V$SESSION new columns from 10.2.0.3 PLSQL_ENTRY_OBJECT_ID PLSQL_ENTRY_SUBPROGRAM_ID PLSQL_OBJECT_ID PLSQL_SUBPROGRAM_ID • Dump errorstack shows PL/SQL line number info: *** 2008-12-05 11:43:17.781 ksedmp: internal or fatal error Current SQL statement for this session: BEGIN dbms_lock.sleep(100); END; ----- PL/SQL Call Stack ----- object line object handle number name 201 package body SYS.DBMS_LOCK 20496E0C 1 anonymous block 204E46E8
  • 32. Scripts for low-level Oracle diagnosis - demos • dstackprof DTrace based stack profiler • ostackprof oradebug short_stack based stack profiler • latchprofx session level latch holder profiling script plain SQL! includes info in which function in Oracle kernel the latch get was invoked Tanel Poder
  • 33. What if my problem lies outside Oracle? …Where to look next? Tanel Poder
  • 34. Oracle internal process flow Time APP Application OCI Oracle Call Interface UPI User program interface Oracle SQL*Net, Two-Task Common Net/TTC OS/TCP TCP/IP Net Ethernet / WAN link OS/TCP TCP/IP Oracle SQL*Net, Two-Task Common Net/TTC Oracle Wait Interface OPI Oracle Program Interface V$SESSTAT kks Kernel Kompile Shared (cursors) qer V$... Query Execution Runtime kcb Kernel Cache Buffer management ksf Kernel Service File i/o skgf (OSD) System Kernel Generic File ? OS OS / IO system calls Tanel Poder
  • 35. Oracle internal process flow APP Application Application instrumentation, ltrace, truss -uquot;libclntsh:*quot; OCI Oracle Call Interface $OH/rdbms/demo/ociucb.mk, OCITrace UPI User program interface - Oracle SQL*NET, TNS, Two-Task Common SQL*Net trace, Wireshark TNS protocol digester Net/TTC OS/TCP TCP/IP Wireshark TCP protocol digester, truss, strace Net Ethernet / WAN link snoop, tcpdump, Wireshark OS/TCP TCP/IP Wireshark TCP protocol digester, truss, strace Oracle SQL*NET, TNS, Two-Task Common SQL*Net trace, Wireshark, Event 10079 Net/TTC OPI Oracle Program Interface Event 10051 kks Kernel Kompile Shared (cursors) sql_trace, Event 10046, 10270, cursortrace qer Query Execution Runtime v$sql_plan_statistics, v$sql_plan_statistics_all, sql_trace kcb Kernel Cache Buffer management x$kcbsw, Event 10200,10812, _trace_pin_time ksf Kernel Service File i/o v$filestat, v$tempstat, v$session_wait, Event 10298 skgf (OSD) System Kernel Generic File ? - OS OS / IO system calls DTrace, strace, truss, tusc, filemon.exe, procmon.exe Tanel Poder
  • 37. Repeat: Session troubleshooting sequence 1. Oracle Wait Interface - response TIME! ? 2. v$sesstat performance counters - hints, indicators ? 3. Process stack - truth about process execution !!! Tanel Poder
  • 38. Session-level troubleshooting tools 1. Profile session wait / CPU breakdown - TIME! V$SESSION_WAIT V$SESSION_EVENT, V$SESS_TIME_MODEL (10g+) Snapper, Sesspack, Statspack session mode 2. Profile session performance counters - occurrences V$SESSTAT 3. Profile session's process stack - statistical sample pstack, procstack, ostackprof, dstackprof procmon.exe, procexp.exe oradebug short_stack, oradebug errorstack Tanel Poder
  • 39. A slide to prove that I do use GUIs... occasionally ;-) Tanel Poder
  • 40. References • Metalink notes: 459694.1 - Procwatcher: Script to Monitor and Examine Oracle and CRS Processes 175982.1 - ORA-600 Lookup Error Categories (explains function names) • Web: http://blog.tanelpoder.com http://www.juliandyke.com/Diagnostics/Diagnostics.html • Seminar: If you like this stuff, you'll definitely like my seminar! http://blog.tanelpoder.com/seminar/
  • 41. Questions? Further questions welcome at http://blog.tanelpoder.com
  • 42. Thank you! Tanel Põder tanel@tanelpoder.com http://www.tanelpoder.com