13 performance tuning

Upload: nravi39763

Post on 13-Feb-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/23/2019 13 Performance Tuning

    1/19

    DB2 for Linux, Unix, and

    Windows

    - Ravi

  • 7/23/2019 13 Performance Tuning

    2/19

    Performance Tuning

  • 7/23/2019 13 Performance Tuning

    3/19

    DB2EXFMT

  • 7/23/2019 13 Performance Tuning

    4/19

    To generate explain plan

    For Example !reate "U#T$%ER ta&le wit' out ()DE* as &elow+&in&as'd&2 !onne!t to DB./d&2 0drop ta&le !ustomer0/d&2 0drop se1uen!e se10/d&2 3!reate ta&lespa!e userspa!e4/d&2 3!reate ta&lespa!e idxspa!e4

    d&2 0!reate ta&le !ustomer 5!id integer, !name "67R52899 () U#ER#:7"E (ndex in(D*#:7"E L$); () U#ER#:7"E0/d&2 0!reate se1uen!e se10/for i in dod&2 0(nsert into "U#T$%ER values 5)E*T?7L for se1, @Testing@90/done

    d&2 3runstats on ta&le !ustomer and detailed indexes all4d&2 !ommit/d&2 !onne!t reset/d&2 terminate/

    d&2 3!onne!t to DB.4

    d&2 3sele!t !ount5A9 from !ustomer4

  • 7/23/2019 13 Performance Tuning

    5/19

    $ db2 set !urrent explain mode explain

    $ db20sele!t !id from !ustomer w'ere !id 88 and !id C0#L82W T'e statement was not exe!uted as onlG Explain information re1uestsare &eing pro!essed= #L#T7TEH8I8J

    $ db2exfmt -d DB1 -o customer.outDB2 Universal Data&ase ?ersion 8=K, KI22-8JJ 5!9 "opGrig't (B% "orp= , 282Li!ensed %aterial - :rogram :ropertG of (B%

    (B% D7T7B7#E 2 Explain Ta&le Format Tool

    "onne!ting to t'e Data&ase="onne!t to Data&ase #u!!essful=Enter up to 2I !'ara!ter Explain timestamp 5Default -9 HHEnter up to 2 !'ara!ter sour!e name 5#$UR"EM)7%E, Default NN9 HH

    Enter sour!e s!'ema 5#$UR"EM#"6E%7, Default NN9 HHEnter se!tion num&er 58 for all, Default 89 HH$utput is in !ustomer=out=Exe!uting "onne!t Reset -- "onne!t Reset was #u!!essful=

    $ db2 set !urrent explain mode no

  • 7/23/2019 13 Performance Tuning

    6/19

    Access Pan! "from customer.out#-----------

    Total "ost %.2&' uerG Degree

    Rows RETUR) 5 9 "ost

    ($ O TB#"7) 5 29 I=2IK

    8 O 888T7BLE DB2()#T2 "U#T$%ER

  • 7/23/2019 13 Performance Tuning

    7/19

    )ow generate explain plan &G !reating Uni1ue index

    db2 0!reate uni1ue index idxM!ustomer on !ustomer5!id9 0db20runstats on ta&le !ustomer and detailed indexes all 0

    db2 set !urrent explain mode explain

    db2 0sele!t !id from !ustomer w'ere !id 88 and !id C 0

    db2exfmt-d testd& -o !ustomer=out

    db2 set !urrent explain mode no

  • 7/23/2019 13 Performance Tuning

    8/19

    Access Pan! "from customer.out#-----------

    Total "ost (1.2()% uerG Degree

    Rows RETUR) 5 9 "ost

    ($ O (*#"7) 5 29 .=2.8

    J=J O 888()DE* DB2()#T2 (D*M"U#T$%ER

  • 7/23/2019 13 Performance Tuning

    9/19

    DB2EXP*+

  • 7/23/2019 13 Performance Tuning

    10/19

    ui!P met'od of getting a explain plan

    (t doesnQt populate explain ta&les 5==mis!E*:L7()=DDL9

    db2ex,n-data&ase DB. -statement 0sele!t !id from !ustomer w'ere !id 880 -terminalEstimated "ost H .=.88JJ8Estimated "ardinalitG H 88=8888I

    7!!ess Ta&le )ame H DB2()#T2="U#T$%ER (D H 2,2KIO (ndex #!an )ame H DB2()#T2=(D*M"U#T$%ER (D H O O Regular (ndex 5)ot "lustered9

    O O (ndex "olumnsO O O "(D 57s!ending9O +"olumns H O #Pip (nserted RowsO 7void Lo!Ping "ommitted DataO "urrentlG "ommitted for "ursor #ta&ilitGO +SeG "olumns H O O #tart SeG Ex!lusive ?alueO O O 88

    O O #top SeG Ex!lusive ?alueO O O )ULLO (ndex-$nlG 7!!essO (ndex :refet!' #e1uential5J9, Reada'eadO Lo!P (ntentsO O Ta&le (ntent #'areO O Row )ext SeG #'areO #arga&le (ndex :redi!ate5s9O O Return Data to 7ppli!ation

    O O O +"olumns H Return Data "ompletion

  • 7/23/2019 13 Performance Tuning

    11/19

    DB2AD/

  • 7/23/2019 13 Performance Tuning

    12/19

    7dvises users on !reation of materialied 1uerG ta&les 5%T9 and indexes,repartitioning of multidimensional !lustering 5%D"9 ta&les, and t'e deletion of unusedo&e!ts

    T'e re!ommendations are &ased on one or more #L statements provided &G t'e user

    For Exam,e!db2 0 describe tabe student

    Data tGpe "olumn

    "olumn name s!'ema Data tGpe name Lengt' #!ale )ulls------------------------------- --------- ------------------- ---------- ----- ------#(D #V#(B% ()TE;ER J 8 Ves#)7%E #V#(B% "67R7"TER .8 8 Ves

    2 re!ord5s9 sele!ted=

    db2 0 seect count"# from student

    ----------- 28J

    re!ord5s9 sele!ted=

  • 7/23/2019 13 Performance Tuning

    13/19

    db2ad3is -d db( -s 4seect count"sid# from student5

    --

    ---- L(#T $F RE"$%%E)DED ()DE*E#-- HHHHHHHHHHHHHHHHHHHHHHHHHHH-- indexX, K=K.%B "RE7TE ()DE* 0DB2()#T20=0(D*J82K8K80 $) 0DB2()#T20=0#TUDE)T0 50#(D0 7#"9 7LL$W RE?ER#E #"7)# "$LLE"T #7%:LED DET7(LED #T7T(#T("#/ "$%%(T W$RS /

    Y

  • 7/23/2019 13 Performance Tuning

    14/19

  • 7/23/2019 13 Performance Tuning

    15/19

  • 7/23/2019 13 Performance Tuning

    16/19

  • 7/23/2019 13 Performance Tuning

    17/19

  • 7/23/2019 13 Performance Tuning

    18/19

  • 7/23/2019 13 Performance Tuning

    19/19