Con8139 Database Time-Based Performance Tuning

  • Upload
    girgl

  • View
    220

  • Download
    0

Embed Size (px)

Citation preview

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    1/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Database Time-Based Performance

    TuningFrom Theory to Practice

    Graham WoodArchitect

    Real-World Performance, Server TechnologiesOctober 1, 2014

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    2/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Real-World Performance Root Causes

    The database is not being usedas it was designed to be used

    The applicationarchitecture/code design is sub-optimal

    There is a sub oin the database

    10/3/2014

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    3/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Program Agenda

    DB Time and Average Active Sessions

    The DB Time Method

    Tools and Whats New

    1

    2

    3

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    4/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Program Agenda

    DB Time and Average Active Sessions

    The DB Time Method

    Tools and Whats New

    1

    2

    3

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    5/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Why Do We Care About Time?

    Human time is critical to the enterprise

    Systems performance affects business goals

    Human time + technology resource time

    Time is money

    Performance improvement means doing things faster

    Performance is always and only about time

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    6/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Database Time (DB Time)

    Total time in database calls by foreground sessions

    Includes CPUtime, IOtime and non-idlewaittime

    DB Time response time

    Common currency for Oracle performance analysis

    Database time is total time spent by user processes either actively w

    or actively waiting in a database call.

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    7/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Single session with Database Black Box server

    A Single Session

    Browse

    Books Read ReviewsFor One BookAdd to Cart

    Checkout

    T= time spent in database

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    8/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Active Session =Session currently spending time in a database call

    Database Time (DB Time) =

    Total time session spent in all database calls

    Average Activity of the Session (% Activity) =

    The ratio of time active to total wall clock time

    Browse

    Books Read ReviewsFor One BookAdd to Cart

    Checkout

    T= time spent in database

    Fundamental Concepts

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    9/52Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    10/52Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    = time spent in database

    Multiple Sessions

    TIMEt

    At time twe have 2 active sessions

    DB Time = Sum of DB Time Over All Sessions

    Avg. Active Sessions = Sum of Avg. Activity Over All Sessions

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    11/52Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Avg. Active Sessions =

    Wall Clock (Elapsed) Time

    Total Database Time

    TIME

    t0 t1

    Active Sessions over time

    1

    2

    3

    4

    Visualizing DB Time

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    12/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    EM Performance Page

    Active Sessions by wait class over time

    Colored area = amount of DB time

    Click on the big stuff

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    13/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Average active sessions

    Full-time equivalent sessions

    Not whole sessions

    How many full-time virtual sessions to do the work?

    Comparable

    Across systems

    Across time periods

    = DB time / elapsed time

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    14/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    More users

    => More calls => DB time increases

    Larger transactions

    => Longer calls

    => DB time increases

    IO performance degrad

    => IO time increases => DB time increases

    Application performan

    => Wait time increases

    => DB time increases

    System Variables and DB Time

    DB time increases as system load increases.

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    15/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Host Performance and DB Time

    Host is CPU-bound

    => foregrounds accumulate active run-queue time => wait event times are artificially inflated

    => DB time increases

    Tune for CPU before waits when CPU constrained

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    16/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    CPU Run-queue and DB Time

    Db file sequential read

    Run-queue

    On CPU Db file sequential read

    Run-queue

    DB time is inflated when host is CPU-bound

    Actual wait time Actual wait time

    Recorded wait time Recorded wait time

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    17/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    System performance and DB time

    CPU or I/O problem?

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    18/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Instrumentation: Where to find DB Time?

    V$SYS_TIME_MODEL, V$SESS_TIME_MODEL

    STAT_NAME = DB time

    V$SYSMETRIC_HISTORY

    Database Time Per Second, CPU Usage Per Sec

    11g new metric Average Active Sessions

    V$SQL ELAPSED_TIME and CPU_TIME

    Wait class times: APPLICATION, CONCURRENCY, CLUSTER, USER_IO

    V$ACTIVE_SESSION_HISTORY

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    19/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Active Session History (ASH)

    All Active sessions captured every second Foregrounds and backgrounds are sampled

    Active foregrounds contribute to DB Time

    Many dimensions captured

    In-memory: V$ACTIVE_SESSION_HISTORY Sampling interval = 1 second

    On-disk: DBA_HIST_ACTIVE_SESS_HISTORY Sampling interval = 10 second

    ASH is a system-wide record of database activity

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    20/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    ASH Math

    COUNT(*) = DB Time

    GROUP BY ?

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    21/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    ASH Math: COUNT(*)=DB Time

    ASH is a big fact table

    Each row represents 1-second of active session time

    V$ACTIVE_SESSION_HISTORY

    COUNT(*) = DB time in seconds

    DBA_HIST_ACTIVE_SESS_HISTORY

    COUNT(*) * 10 = DB time in seconds

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    22/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Example: DB Time by SQL IDselect sql_id

    , count(*) DBTime

    , round(count(*)*100/sum(count(*))over (), 2) pctload

    from v$active_session_history

    where sample_time > sysdate - 1/24/60

    and session_type 'BACKGROUNDgroup by sql_id

    order by count(*) desc;

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    23/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    select sql_id

    , count(*) DBTime

    , round(count(*)*100/sum(count(*))

    over (), 2) pctloadfrom v$active_session_history

    where sample_time > sysdate - 1/24/60

    and session_type 'BACKGROUND'

    group by sql_id

    order by count(*) desc;

    SQL_ID DBTIME PCTLOAD

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

    6bmxrabnwwsxd 60 63.83

    azzsynmz43nrr 8 8.51

    28pb73sbwhmm8 5 5.32

    58psyvgau23s2 3 3.19

    amrq8hk767tuz 2 2.13

    2r5qhb3fb63vm 1 1.06

    f3919usqp5wj2 1 1.06

    Example: DB Time by SQL ID

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    24/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    timet0

    Avg Active Sessions and DB TimeActive sessions

    t = 1 sec

    ASH sample count is value of active

    sessions function at sample times

    DB Time

    DB time is area under curve

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    25/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    DB Time: ASH vs Time Model

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    26/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Where is DB Time used?

    ADDM

    EM Performance page and drill downs

    ASH report

    AWR and AWR Warehouse

    SQL Monitor and Perfhub

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    27/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Program Agenda

    DB Time and Average Active Sessions

    The DB Time Method

    Whats New

    1

    2

    3

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    28/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    The DB Time Method: Short Course

    Determine where database time is spent, an

    reduce it!or

    just ask ADDM

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    29/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    The DB Time Method

    1. Identify performance issue

    2. Scope the issue3. Set goals

    4. Data capture (NO OP)

    5. Investigate DB time distribution

    Identify the largest potential for improvement

    6. Modify system to tune for largest gain

    7. Evaluate against goals

    Repeat from step 4 if goals not met

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    30/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Investigate DB Time Distribution

    Identify uneven distributions of DB time (skew)

    Largest potential improvement within scope

    If CPU bound tune for CPU first!

    System scope:

    Resource limitsis problem outside the DB?

    Application scope:

    Service, module, action

    Resource contention (e.g. latches) SQLID, rowsource

    Session scope

    Long running SQL

    Resource contention (e.g. enqueues)

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    31/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    DB time

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    32/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Modify System

    Start with the largest DB time issues first

    Address root causes, not symptoms

    Match solution scope to problem scope

    Scope mismatch causes many problems

    Proceed iteratively, one fix at a time

    Concurrent fixes should be orthogonal

    Measure and validate results at each successive step

    Stop when goals are met

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    33/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    The DB Time Method: Advantages

    Tunes the one thing that affects users: Time

    Data capture scoping not necessary Always on data collection

    No requirement to reproduce problem

    DB time based diagnosis removes value judgments

    Scientific method, not sorcerers magic

    Works for concurrency problems such as locking

    Performance improvement means doing the same work in les

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    34/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Program Agenda

    DB Time and Average Active Sessions

    The DB Time Method

    Tools and Whats New

    1

    2

    3

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    35/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    AWR ReportingAWR, ASH, Compare period etc

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    36/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    AWR ReportingAWR, ASH, Compare period etc

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    37/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    ADDM

    Embedded expert system using the DB time method

    Identifies root causes behind the symptoms Variably scoped:

    Host to instance to SQL and even database block

    Scoped to database for RAC (new in 11g)

    Real-time ADDM with 12c

    Findings prioritized by impact on DB time

    Finding history allows flexible time scoping

    Directives can filter findings

    Recommendations by benefit (reduction) to DB time

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    38/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    39/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    40/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    EM Real-time Interface

    Transient (sub-hour) or immediate time scope

    Requires interactivity of UI

    Click on the big stuff

    Data visualizations display skew directly

    Takes some expertise to separate symptoms from root causes

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    41/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    42/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    43/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    44/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    45/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Grid Control DB Loadmap

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    46/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Grid Control DB Loadmap

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    47/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    ASH Analytics

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    48/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    Warehouse dashboard trac

    All AWR features available

    data

    Performance page

    AWR report

    ASH analytics

    Compare Period ADD

    Compare Period Repo

    Integrated seamlessly into

    Zero runtime overhead on

    AWR Warehouse

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    49/52

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    50/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    51/52

    Copyright 2014, Oracle and/or its affiliates. All rights reserved. |

    DB Time

    Instrumentation and reporting across many different scopes

    Allows engineering approach to performance diagnosis

    Built into new features of Oracle Database such as DBIM

  • 8/9/2019 Con8139 Database Time-Based Performance Tuning

    52/52