database technology 1 craig shallahamer sql elapsed time analhysispdf1213

Upload: felix-mateos-medrano

Post on 03-Mar-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    1/32

    !"# %&'()*+ ,-.* /0'&1)-)

    SQL

    Elapsed TimeAnalysis

    Craig A. ShallahamerFounder - OraPub, Inc.

    [email protected]

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    2/32

    !"# %&'()*+ ,-.* /0'&1)-)

    OraPub is about Oracle performance.

    OraPub is all about Oracle performance

    management; systematic and quantitativefirefighting and predictive analysis.

    Web site started in 1995 and the company was

    founded in 1998 by Craig Shallahamer.

    OraPub has always been about disseminating

    Oracle database centric technical information.

    Consulting, training, books, papers, and

    products are now being offered.

    We have been on-site in 24 countries and our

    resources have been received in probably

    every country where there are DBAs.

    2"#$%&%&'

    2(&%)*+ ,-.'

    2

    /#++ "..-0

    2/#++ 1$2+#0

    2

    ,..3021#.4*560

    27.&0*-8&'

    9+0.*#5+0

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    3/32

    !"# %&'()*+ ,-.* /0'&1)-)

    Short resume...kind of...

    Studies economics, mathematics, and computer science at

    university in California, US.

    Started working with Oracle technology in 1989 as a Forms 2.3

    developer on Oracle version 5.

    Soon after started performance firefighting...daily!

    Co-found both Oracles Core Technology and System

    Performance Groups.

    Left Oracle to start OraPub, Inc. in 1998.

    Authored 24 technical papers and worked in 24 countries.

    Authors and teaches his classes Oracle Performance

    Firefighting,Adv Oracle Performance Analysis, and Oracle

    Forecasting & Predictive Analysis. Authored the books, Forecasting Oracle Performanceand

    Oracle Performance Firefighting.

    Oracle ACE Director.

    Frequent blog contributor: A Wider View

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    4/32

    !"# %&'()*+ ,-.* /0'&1)-)

    My two books...3

    4'567+-)8960:89+

    *;

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    5/32

    !"# %&'()*+ ,-.* /0'&1)-)

    One presentation with two parts.

    The average can be misleading.

    Modeling E time leads to insights.

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    6/32

    !"# %&'()*+ ,-.* /0'&1)-)

    Working with limited information.SQL ordered by Elapsed DB/Inst: LOOK/LOOK Snaps: 80298-80310

    -> Resources reported for PL/SQL code includes the resources used by all SQL

    statements called by the code.-> Total DB CPU (s): 22,800

    -> Captured SQL accounts for 109.8% of Total DB CPU

    -> SQL reported below exceeded 1.0% of Total DB CPU

    CPU CPU per Elapsd Old

    Time (s) Executions Exec (s) %Total Time (s) Physical Reads Hash Value

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

    474.59 38,479 0.01 19.9 479909.89 923,822,548 4166296332

    BEGIN pkg_com_unite.st_execute_commune( i_daemon_id => :daemon_id,

    i_reload_subult_true_false => :reload_subult_true_false,

    i_dump_caches => :dump_caches, i_add_seq2_id => :add_seq2_id,

    i_dump_seq2_id => :dump_seq2_id, i_remove_seq2_id => :remove_seq2_id,

    i_multi_seq2_chg_true_false => :multi_seq2

    ,9:'& %&'()*+ ,-.* ; >?@A@B@CD@ )*890+)

    ,9:'& %E*86F90) ; GDA>?@ *E*8

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    7/32!"# %&'()*+ ,-.* /0'&1)-)

    So the average E time is...

    E = 479909.89 secs / 38,479 exec= 12.47 sec/exec

    0.*#5+: ;&%6 ?&@

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    8/32!"# %&'()*+ ,-.* /0'&1)-)

    Its more likely to be like this...

    H94*I J&9K 094.'&L

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    9/32!"# %&'()*+ ,-.* /0'&1)-)

    Even more likely...

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    10/32!"# %&'()*+ ,-.* /0'&1)-)

    What can we do?

    We dont want to mislead others.

    We need to truly understand the

    situation if we are making decisionsbased on this information.

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    11/32!"# %&'()*+ ,-.* /0'&1)-)

    We have a variety of collection options.

    SQL Trace. Valid option. Must have ability to parse the trace files producing E times.

    Can trace on sql_id.

    Must be the production system.

    Instrument SQL. Valid option. May not be practical or possible.

    Stopwatch. Risky. Limited scope and very few samples.

    OK for a specific user situation.

    Benchmark or Isolated Testing. Very risky. If you want real results, you need a real situation (HW, data, arrivals, concurrency).

    OraPub E Time Collector. Valid, but grabs a core. Free tool. OraPub search: sql elapsed time

    Gathers at sql_idand plan_hash_valuelevel.

    Grabs and holds a CPU core, ouch!

    OraPub E Sampler. Valid but not free. Un-noticeable impact with same results as tracing or instrumentation!

    Gathers at sql_idlevel and samples stored in Oracle table.

    Licensed like a box of candy.

    Beta version available for Insync attendees....free!H94*I J!"# )'.(&*4L

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    12/32!"# %&'()*+ ,-.* /0'&1)-)

    How good is sampled data?

    ,M-) -) ).99:M*+ M-):9K4'. 9N *&'()*+ F.*) N94 '

    )(*8-O8 sql_idPQ6*41R 89&&*8:*+ 6)-0K !"#

    ,4'8*A -0):46.*0:'F90A '0+ 35 %&'()*+ F.*

    !'.(&*4 P094.'&RC 3S*4 ' T .-06:* (*4-9+A '4960+

    DB )'.(&*) UM*4* K':M*4*+ N49. *'8M 89&&*8F90.*:M9+C

    /&& :M4** 89&&*8F90) .*:M9+)

    (49+68* :M* )'.* 4*)6&:)V

    H94*I ,46* !"# %&'()*+

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    13/32!"# %&'()*+ ,-.* /0'&1)-)

    Lets take a look at some

    real datafrom

    real systems.

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    14/32!"# %&'()*+ ,-.* /0'&1)-)

    #1: Showing all samples.

    )9648*; /7*4G=W@

    Samples : 230

    Mean : 57168

    Median : 60000

    Max : 793996

    Collector: OP E Time

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    15/32!"# %&'()*+ ,-.* /0'&1)-)

    #1: Showing most samples.

    )9648*; /7*4G=W@

    Samples : 230

    Mean : 57168

    Median : 60000

    Max : 793996Collector: OP E Time

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    16/32!"# %&'()*+ ,-.* /0'&1)-)

    #2: Showing most samples.

    )9648*; X'44*:=YQY

    Samples : 368Mean : 158

    Median : 23

    Max : 2840

    Collector: OP E Time

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    17/32!"# %&'()*+ ,-.* /0'&1)-)

    #3: Showing all samples.

    )9648*; X'44*:DQ:

    Samples : 506Mean : 48

    Median : 26

    Max : 476

    Collector: OP E Time

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    18/32!"# %&'()*+ ,-.* /0'&1)-)

    #4: Showing all samples.

    )9648*; X'44*: B6W:

    Samples : 179Mean : 38.72 ms

    Median : 38.04 ms

    Max : 58.40 ms

    Collector: OP E Sampler

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    19/32!"# %&'()*+ ,-.* /0'&1)-)

    Experimental Examples.

    )9648*; % /0'&1)-) =' PO0'&RC07

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    20/32

    !"# %&'()*+ ,-.* /0'&1)-)

    Conclusions about average E.

    Average elapsed time for a specific SQL

    statement can be very misleading. Elapsed times are not normally distributed.

    The averageelapsed time is not the typical

    elapsed time. The modes are the typical elapsed times.

    If the mode is not available, then the median

    can be used, in some cases. If you need to communicate typical elapsed

    times, you need to gather real data.

    H94*I J!"# *&'()*+L

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    21/32

    !"# %&'()*+ ,-.* /0'&1)-)

    Modeling elapsed time

    E =units of work xtime per unit

    E (time/exec) =WL(work/exec) xRT(time/work)

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    22/32

    !"# %&'()*+ ,-.* /0'&1)-)

    Example of elapsed time.

    !6((9)*+ ' Q6*41 .6): '88*)) =BBABBB &9K-8'&

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    23/32

    !"# %&'()*+ ,-.* /0'&1)-)

    When we tune, WL is reduced.

    SQL tuning fundamentally reduces the

    work required to execute a statement.

    Since less work is required then generally,

    the elapsed time will decrease!

    If your tuning prowess reduces the work

    from 100,000 PIOs to 50,000 PIOs then

    you can expect the elapsed time to

    decrease by 50%.

    But does this really occur in reality? hum...

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    24/32

    !"# %&'()*+ ,-.* /0'&1)-)

    Experimental results!

    "*&+4ABC

    A6D6C.'%5$-

    ;E

    A6D6 C;E7F$&'+

    G+4%$&H-$20+4

    "%D+ I0J

    G+4%$&

    H-$20+4"%D+ I0J

    7F$&'+

    A$D2-+0

    [9 GTTWD@ \ =>CWW \ W>G

    ]*) =^=>@T \T>CTT_ TCDD \TDC^?_ GG@

    `9&&*8F90 -0:*4S'& U') W M964)C

    "#$%&'() *+$,)-. /01- 2$1,+-#U') 6)*+ :9 89&&*8: *&'()*+ F.*)C

    #

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    25/32

    !"# %&'()*+ ,-.* /0'&1)-)

    Ways to reduce UOW process time.

    There are many ways to reduce the time it

    takes to process a single unit of work. There are direct methods and indirect

    methods.

    Indirect: Because processes share andcompete for resources, when the big issue isresolved, many other issues become lessintense.

    Direct: Tuning Oracle directly reduces thetime required to process a piece of work.Hum...

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    26/32

    !"# %&'()*+ ,-.* /0'&1)-)

    Experimental results!

    7,7C$65F+0

    ;&06$&5+

    9"

    ID0K-%.J

    7F$&'+

    ;&06$&5+

    =C

    I-%.KD0J

    ABC A6D6

    G+4%$&H-$20+4

    "%D+ I0J

    7F$&'+ A$D2-+0

    WT^ BCBG^WG \ =WB =>CWW> \ W>G

    GW?^D BCBBDT^ \?^CG^_ WW? WC@^D \?@C=G_ G@@

    `9&&*8F90 -0:*4S'& U') W M964)C "#$%&'() *+$,)-. /01- 2$1,+-#U') 6)*+ :9 89&&*8: *&'()*+ F.*)C

    b, 89.(90*0:) K':M*4*+ N49. Sa)1)):':A Sa)1)cF.*c.9+*&A '0+ Sa)1):*.c*S*0:C

    ,-.* 7')*+ 90 F.*):'.( +':' :1(*C

    )9648*; % /0'&1)-) ='CE&)EA 09: :60*+

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    27/32

    !"# %&'()*+ ,-.* /0'&1)-)

    This graph shows the work process time.

    )9648*; H94* #':8M*) b, `9.('4*CCCE&)E

    LMNO 9" 7F$&'+

    PQNO =C 7F$&'+

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    28/32

    !"# %&'()*+ ,-.* /0'&1)-)

    All situations elapsed times.

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    29/32

    !"# %&'()*+ ,-.* /0'&1)-)

    The point? #1 Average is misleading.

    It is easy to calculate the average elapsed

    time...even from Statspack.

    But saying, The average elapsed time is X.

    will most likely mislead everyone.

    The median or mode(s) is a much better

    representation of the typical elapsed times.

    If you need to communicate typical elapsed

    times, you need to gather real data.

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    30/32

    !"# %&'()*+ ,-.* /0'&1)-)

    The point? #2 Modeling SQL E.

    Two basic ways to reduce elapsed times:

    Reduce work to be done.

    Reduce time to process each piece of work.

    SQL statement elapsed time can be

    simply modeled.

    SQL statement elapsed time can beanticipated.

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    31/32

    !"# %&'()*+ ,-.* /0'&1)-)

    Want to dig deeper?

    Craigs Blog A W i d e r V i e w

    Trainingfrom OraPub

    Oracle Performance Firefighting (I)

    Adv Oracle Performance Analysis (II) Books

    Oracle Performance Firefighting (C. Shallahamer)

    Chapter 9 is FREE to download

    G+-@.*#&+

    R 1+#6F %&

    B> >ST>

  • 7/26/2019 Database Technology 1 Craig Shallahamer SQL Elapsed Time Analhysispdf1213

    32/32

    Thank

    You!