db2 performance primer_new

Upload: abdul-gafur

Post on 14-Apr-2018

229 views

Category:

Documents


1 download

TRANSCRIPT

  • 7/30/2019 DB2 Performance Primer_New

    1/33

    DB2 Performance Primer

    Baltimore/Washington DB2 Users Group

    December 10, 2003

    Michael Murray

    Senior Consultant

    [email protected]

  • 7/30/2019 DB2 Performance Primer_New

    2/33

    Presentation Overview

    How Does DB2 Get Data? Index Considerations

    Tablespace Considerations

    Tune the SQL to Get the Biggest Bangfor your Buck

    Access Paths What are the Choices?

  • 7/30/2019 DB2 Performance Primer_New

    3/33

    DB2 SubsystemDatabase

    Tablespace

    Table

    Page

    Page

    Row

    Indexspace

    Index

    Page

    Page

  • 7/30/2019 DB2 Performance Primer_New

    4/33

    What is a Page?

    4K page, maximum number of data bytes on the page 4,074.

    Maximum row size 4,056. Row size greater than 2,020

    bytes will end up with just one row per page.

    4K

    8K

    16K

    32K

    GETPAGE

    Physical I/O

    Your Data

    Row Limits

    PSIDpage set identifier

  • 7/30/2019 DB2 Performance Primer_New

    5/33

    DBM1 Address Space

    SQL, DDL, DML, DCL

    Optimization

    Data Manager

    Relational Data System

    Buffer Manager

    Sort Pool EDM Pool

    RID Pool

    Bind/Rebind

    IRLM Interaction

    Locking

    IRLM

    Directory Catalog

    WorkFile User Data

    DSNDB01 DSNDB06

    DSNDB07

    Database ServicesDBM1

    SQL

    stored procedures

  • 7/30/2019 DB2 Performance Primer_New

    6/33

    DB2 Stogroups

    STOGROUP GPRVVOL

    Volume

    B2RP03

    Volume

    B2RP02

    Volume

    B2RP01

    CREATE STOGROUP GSMSVOL

    VOLUMES(*)

    VCAT S0;

    CREATE STOGROUP GPRVVOL

    VOLUMES(B2RP01

    ,B2RP02,B2RP03)

    VCAT P0;

    Non-SMS User Managed Stogroup

    SMS Managed Stogroup

  • 7/30/2019 DB2 Performance Primer_New

    7/33

    SMS Allocations

    indexspace

    volume PBP2

    Storage Group I

    cache

    indexspacevolume PBP8

    cache

    tablespace

    volume PB34

    Storage Group T

    cache

    tablespacevolume PBL8

    cache

    ACS Routines

    (4th

    node is NOT X or I) (4th

    node is X or I)

    Tablespace or Indexspace Allocations

    (Create, Extent Allocation, Load, Reorg)

    DB2

    SMS

  • 7/30/2019 DB2 Performance Primer_New

    8/33

    Buffer Pool Strategy

    DSNDB07DSNDB01DSNDB06

    BP0 BP7

    Default

    Tablespace

    BP48

    Default

    Indexspace

    BP49

    CRM

    Indexes

    BP5

    CRM

    Tablespaces

    BP8

    ERP

    Indexes

    BP3

    ERP

    Tablespaces

    BP6

    Critical Path

    Indexes

    BP1

    Critical Path

    Tablespace

    BP2

    DSNDB04

    BP4

    Other

    Indexes

    BP9

    Other

    Tablespaces

    BP10

    32K

    Tablespaces

    BP32K

    RandomTablespaces

    BP12

  • 7/30/2019 DB2 Performance Primer_New

    9/33

  • 7/30/2019 DB2 Performance Primer_New

    10/33

    DB2s Work File Explained

    DATA MANAGER

    Relational Data System

    STAGE 1 PREDICATES

    STAGE 2 PREDICATES

    sargableindexable

    Filtered Result Set

    DSNDB07

    SORTrequired

    CREATE INDEX

    DEFER NO

    No matching index

    DISTINCT

    ORDER BY

    UNION

    GROUP BY

    Some Joins

    SORT POOL

    3. sort columns

    1. selected columns2. calc/derived values

    key columns, RIDs

    BP7

    sort assist

    hardwareSort assist

    hardware?

  • 7/30/2019 DB2 Performance Primer_New

    11/33

    Index Considerations

    Clustering Vs. Non Clustering

    Unique Vs. Duplicate

    Piecesize with NPIs

    Uniqueness, Performance,RI, Sorting

    Table Size

    Minimize I/O

    1 25 7

    1015

    PRT B PRT L PRT M SG M/L SG S C

    # Indexes

    Index Limits based on # of pages? What's the

    I/O rate per page? Is this even realistic?

    TS Type Number Pages

    Partitioned big > 5,000,000

    Partitioned large < 5,000,000

    > 200,000

    Partitioned medium < 200,000

    > 5,000Segmented medium - large > 5,000

    < 500,000

    Segmented small < 5,000

    Code Tables

    Segmented or Partitioned

    < 200

  • 7/30/2019 DB2 Performance Primer_New

    12/33

    Peaks > 13,999 Feet Located in US

    Indexes:

    Clustered Index on: Elevation (desc), State, Peak Name

    Non-Clustered Index on: Peak Name

    Unique PK Index on: Latitude, Longitude

    Peak Name State Elevation Latitude Longitude Rating

    Mount McKinley AK 20320 630410N 1510013W VERY DIFFICULT

    Mount Bear AK 14831 611702N 1410832W MODERATE

    Mount Whitney CA 14494 363438N 1181733W MODERATE

    Mount Harvard CO 14420 385528N 1061912W EASY

    Mount Rainier WA 14410 465110N 1214531W DIFFICULT

    Goal of indexes is to minimize I/O

  • 7/30/2019 DB2 Performance Primer_New

    13/33

    Elevation (desc)

    State

    Peak Name

    ROOT Page

    Page 552

    14831 AK Mount Bear

    14420 CO Mount Harvard

    p. 501, 2

    p. 502, 2

    LEAF & DATA Page

    Page 553

    14270 CO Grays Peak

    14196 CO Mount Yale p. 504, 2

    p. 503, 2

    Page 554

    14110 CO Pikes Peak

    14059 CO Sunlight Peak

    p. 505, 2

    Page 555

    14037 CO Little Bear Peak

    14000 CA Thunderbolt Peak

    p. 507, 2

    NON-LEAF Page

    Page 717

    14420 CO Mount Harvard

    14196 CO Mount Yale

    14059 CO Sunlight Peak

    14000 CA Thunderbolt Peak

    p. 553, 2

    p. 554, 2

    p. 552, 2

    p. 508, 2

    20320 AK Mount McKinley

    14831 AK Mount Bear

    Page 502

    14494 CA Mount Whitney

    14420 CO Mount Harvard

    Page 503

    14410 WA Mount Rainier

    14270 CO Grays Peak

    Page 504

    14255 CO Longs Peak

    14196 CO Mount Yale

    Page 505

    14172 CO Mount Bross

    14110 CO Pikes Peak

    Page 506

    14080 CA Starlight Peak

    14059 CO Sunlight Peak

    Page 507

    14058 CA Split Mountain

    14037 CO Little Bear Peak

    Page 508

    14000 CA Thunderbolt Peak

    Page 501

    14005 CO Mount o/t Holy Cross

    p. 555, 2

    p. 506, 2

  • 7/30/2019 DB2 Performance Primer_New

    14/33

    Peak Namep. 401, 2

    Page 301

    Little Bear Peak

    Mount Bear p. 402, 2

    ROOT Page

    NON-LEAF Page

    LEAF Page

    NON-CLUSTERED INDEX 20320 AK Mount McKinley 14831 AK Mount Bear

    Page 502

    14494 CA Mount Whitney

    14420 CO Mount Harvard

    Page 503

    14410 WA Mount Rainier

    14270 CO Grays Peak

    Page 504

    14255 CO Longs Peak

    14196 CO Mount Yale

    Page 505

    14172 CO Mount Bross

    14110 CO Pikes Peak

    Page 506

    14080 CA Starlight Peak

    14059 CO Sunlight Peak

    Page 507

    14058 CA Split Mountain

    14037 CO Little Bear Peak

    Page 508

    14005 CO Mount o/t Holy Cross

    14000 CA Thunderbolt Peak

    DATA Page

    Page 501

    p. 403, 2

    Page 302

    Mount Harvard

    Mount o/t Holy Cross p. 404, 2

    p. 405, 2

    Page 303

    Mount Whitney

    Pikes Peak p. 406, 2

    p. 407, 2

    Page 304

    Starlight Peak

    Thunderbolt Peak p. 408, 2

    p. 301, 2

    Page 201

    Mount Bear

    Mount o/t Holy Cross p. 302, 2

    p. 303, 2

    Page 202

    Pikes Peak

    Thunderbolt Peak p. 304, 2

    p. 201, 2Page 101

    Mount o/t Holy Cross

    Thunderbolt Peak p. 202, 2

    p. 503, 2

    Page 401

    Grays Peak

    Little Bear Peak p. 507, 2

    p. 504, 1

    Page 402

    Longs Peak

    Mount Bear p. 501, 2

    p. 505, 1

    Page 403

    Mount Bross

    Mount Harvard p. 502, 2

    p. 501, 1

    Page 404

    Mount McKinley

    Mount o/t Holy Cross p. 508, 1

    p. 503, 1

    Page 405

    Mount Rainier

    Mount Whitney p. 502, 1

    p. 504, 2

    Page 406

    Mount Yale

    Pikes Peak p. 505, 2

    p. 507, 1

    Page 407

    Split Mountain

    Starlight Peak p. 506, 1

    p. 506, 2

    Page 408

    Sunlight Peak

    Thunderbolt Peak p. 508, 2NON-LEAF Page

  • 7/30/2019 DB2 Performance Primer_New

    15/33

    p. 461, 2

    Page 331

    370116N 1182520W

    370539N 1183124W p. 462, 2

    ROOT Page

    NON-LEAF Page

    LEAF Page

    PRIMARY NON-CLUSTERED INDEX20320 AK Mount McKinley

    14831 AK Mount Bear

    Page 502

    14494 CA Mount Whitney

    14420 CO Mount Harvard

    Page 503

    14410 WA Mount Rainier

    14270 CO Grays Peak

    Page 504

    14255 CO Longs Peak

    14196 CO Mount Yale

    Page 505

    14172 CO Mount Bross

    14110 CO Pikes Peak

    Page 506

    14080 CA Starlight Peak

    14059 CO Sunlight Peak

    Page 507

    14058 CA Split Mountain

    14037 CO Little Bear Peak

    Page 508

    14005 CO Mount o/t Holy Cross

    14000 CA Thunderbolt Peak

    DATA Page

    Page 501

    Latitude

    Longitude

    p. 463, 2

    Page 332

    373738N 1073543W

    385039N 1061848W p. 464, 2

    p. 465, 2

    Page 333

    392007N 1060625W

    393802N 1054901W p. 466, 2

    p. 467, 2

    Page 334

    465110N 1214531W

    630410N 1510013W p. 468, 2

    p. 331, 2

    Page 281

    370539N 1183124W

    385039N 1061848W p. 332, 2

    p. 333, 2

    Page 282

    393802N 1054901W630410N 1510013W p. 334, 2

    p. 281, 2Page 101

    385039N 1061848W

    630410N 1510013W p. 282, 2

    p. 502, 1

    Page 461

    363438N 1181733W

    370116N 1182520W p. 507, 1

    p. 506, 1

    Page 462

    370539N 1183119W

    370539N 1183124W p. 508, 2

    p. 507, 2

    Page 463

    373400N 1052948W

    373738N 1073543W p. 506, 2

    p. 505, 2

    Page 464

    385026N 1050238W

    385039N 1061848W p. 504, 2

    p. 502, 2

    Page 465

    385528N 1061912W

    392007N 1060625W p. 505, 1

    p. 508, 1

    Page 466

    392805N 1062845W

    393802N 1054901W p. 503, 2

    p. 504, 1

    Page 467

    401517N 1053655W

    465110N 1214531W p. 503, 1

    p. 501, 2

    Page 468

    611702N 1410832W

    630410N 1510013W p. 501, 1NON-LEAF Page

  • 7/30/2019 DB2 Performance Primer_New

    16/33

    Adding Columns to an Index

    Improves filtering Provides index only access

    Increases matched columns

    Provides a sequence to avoid SORTS

    Increases cluster ratio

    Helps in index screening

    Is the increased RID chain length negatively

    impacting your non-read transactions?

  • 7/30/2019 DB2 Performance Primer_New

    17/33

    Index Statistics

    Indexes & Stats:

    PK Index on: Latitude, Longitude, Climber_ID, Strt_DT

    NPI: Climber_ID, Summit, O2, Guided

    RUNSTATS TABLESPACE dbname.tsname INDEX(ALL)1st Column & Fullkey Cardinality on all indexesTop 10 most frequent values for 1st column of all indexes

    RUNSTATS INDEX owner.ixname FREQVAL xx NUMCOLS xxGive me the top 15 climbed peaks (FREQVAL 15 NUMCOLS 2 for PK index)

    LATITUDE LONGITUDE CLIMBER_ID STRT_DT END_DT TB_TIME SUMMIT O2 GUIDED

    630410N 1510013W CA000015 4/20/2001 5/28/2001 11:00 YES YES NO630410N 1510013W CA000015 2/11/2000 3/13/2000 10:00 NO NO YES

    630410N 1510013W CE000008 2/7/2000 3/22/2000 12:00 YES YES NO

    630410N 1510013W CE000008 3/3/1999 4/16/1999 13:00 YES YES YES

    630410N 1510013W CE000008 1/14/1998 3/14/1998 15:30 NO YES YES

    630410N 1510013W CJ000033 3/17/2002 5/13/2002 14:30 YES NO NO

    630410N 1510013W CJ000033 12/19/2000 2/14/2001 15:00 NO YES YES

    630410N 1510013W CR000039 2/14/2002 4/9/2002 13:30 YES NO NO

    630410N 1510013W CR000039 3/30/2001 5/12/2001 14:00 YES NO YES

    630410N 1510013W CR000039 1/7/1999 3/10/1999 13:00 NO NO NO

    PEAKS CLIMBED TABLE

    SELECT CLIMBER_ID, LATITUDE,

    LONGITUDE, O2, GUIDED FROMPEAKS_CLIMBED

    WHERE CLIMBER_ID = CE000008 AND

    SUMMIT = YES

    ORDER BY O2, GUIDED WITH UR;

    SORT

    Required?

  • 7/30/2019 DB2 Performance Primer_New

    18/33

    Colvalue CardF FrequencyF

    AK 2 0.1250

    CA 4 0.2500

    CO 9 0.5625

    WA 1 0.0625

    SELECT PEAKNAME FROM PEAKS

    WHERE STATE = CO;

    20320 AK Mount McKinley

    14831 AK Mount Bear

    Page 502

    14494 CA Mount Whitney

    14420 CO Mount Harvard

    Page 503

    14410 WA Mount Rainier

    14270 CO Grays Peak

    Page 504

    14255 CO Longs Peak

    14196 CO Mount Yale

    Page 505

    14172 CO Mount Bross

    14110 CO Pikes Peak

    Page 506

    14080 CA Starlight Peak

    14059 CO Sunlight Peak

    Page 507

    14058 CA Split Mountain

    14037 CO Little Bear Peak

    Page 508

    14005 CO Mount o/t Holy Cross

    14000 CA Thunderbolt Peak

    Page 501

    p. 501, 1

    Page 307

    AK 20320

    p. 501, 2AK 14831

    p. 502, 1

    Page 308

    CA 14494

    p. 506, 1CA 14080

    p. 507, 1

    Page 309

    CA 14058

    p. 508, 2CA 14000

    p. 502, 2

    Page 310

    CO 14420

    p. 503, 2CO 14270

    p. 504, 1

    Page 311

    CO 14255

    p. 504, 2CO 14196

    p. 505, 1

    Page 312

    CO 14172

    p. 505, 2CO 14110

    p. 506, 2

    Page 313

    CO 14059

    p. 507, 2CO 14037

    p. 508, 1

    Page 314

    CO 14005

    p. 503, 1WA 14410

    Colvalue CardF FrequencyF

    AK 21 0.2308

    CA 15 0.1648CO 54 0.5934

    WA 1 0.0110

    SELECT PEAKNAME FROM PEAKS

    WHERE STATE = CO AND

    ELEVATION =14110;

    ColGroupColNo CardF FrequencyF

    AK 20320 1 0.0625

    AK 14831 1 0.0625

    CA xxxxx 1 0.0625

    CO xxxxx 1 0.0625

    WA xxxxx 1 0.0625

    ColGroupColNo CardF FrequencyF

    AK xxxxx 1 0.0110CA xxxxx 1 0.0110

    CA 14162 2 0.0220

    CA 14000 2 0.0220

    CO xxxxx 1 0.0110

    CO 14265 2 0.0220

    CO 14162 2 0.0220

    CO 14042 2 0.0220

    CO 14014 2 0.0220

    CO 14005 2 0.0220

    CO 14197 3 0.0330

    WA 14410 1 0.0110

    RUNSTATS INDEX DB2.STELEV

    FREQVAL 10 NUMCOLS 2

    RUNSTATS TABLESPACE

    dbname.tsname INDEX(ALL)

    DATA PageLEAF Page

    CREATE INDEX DB2.STELEV ON DB2.PEAKS

    STATE, ELEVATION DEFER YES PIECESIZE 2G;

  • 7/30/2019 DB2 Performance Primer_New

    19/33

    List Prefetch

    20320 AK Mount McKinley

    14831 AK Mount Bear

    Page 50214494 CA Mount Whitney

    14420 CO Mount Harvard

    Page 503

    14410 WA Mount Rainier

    14270 CO Grays Peak

    Page 504

    14255 CO Longs Peak 14196 CO Mount Yale

    Page 505

    14172 CO Mount Bross

    14110 CO Pikes Peak

    Page 506

    14080 CA Starlight Peak

    14059 CA Sunlight Peak

    Page 507

    14058 CA Split Mountain

    14037 CO Little Bear Peak

    Page 508

    14005 CO Mount o/t Holy Cross

    14000 CA Thunderbolt Peak

    Page 501

    p. 502, 1

    Page 461

    363438N 1181733W

    370116N 1182520W p. 507, 1

    p. 506, 1Page 462

    370539N 1183119W

    370539N 1183124W p. 508, 2

    p. 507, 2

    Page 463

    373400N 1052948W

    373738N 1073543W p. 506, 2

    p. 505, 2

    Page 464

    385026N 1050238W385039N 1061848W p. 504, 2

    p. 502, 2

    Page 465

    385528N 1061912W

    392007N 1060625W p. 505, 1

    p. 508, 1

    Page 466

    392805N 1062845W

    393802N 1054901W p. 503, 2

    p. 504, 1

    Page 467

    401517N 1053655W

    465110N 1214531W p. 503, 1

    p. 501, 2

    Page 468

    611702N 1410832W

    630410N 1510013W p. 501, 1

    p. 502, 1

    RID LIST

    363438N 1181733W

    370116N 1182520W p. 507, 1

    p. 506, 1370539N 1183119W

    370539N 1183124W p. 508, 2

    373738N 1073543W p. 506, 2

    p. 502, 1

    Sorted RID LIST

    363438N 1181733W

    p. 506, 1370539N 1183119W

    370539N 1183124W p. 508, 2

    373738N 1073543W p. 506, 2

    physicalI/O order

    370116N 1182520W p. 507, 1

    (poor cluster ratio)

    = unwanted disk head movement

    SELECT ELEVATION, PEAKNAME

    FROM PEAKS

    WHERE LATITUDE IN

    (363438N,370116N,370539N,373738N)

  • 7/30/2019 DB2 Performance Primer_New

    20/33

    Tablespace Types

    Segmented Tablespace - 3 table example

    Segmented Tablespace - 1 table example

    Spacemap keeps track of segments (pages) by table.

    Spacemap page in a segmented tablespace helps when a

    program deletes without a where clause by marking thosesegments logically deleted. Spacemap page also makes

    segments tied to dropped tables accessible. Segsize

    between 4-64 increasing in increments of 4. See

    recommendations in notes section.

    Simple Tablespace - 1 table example

    Simple Tablespaces can have multiple tables;

    however, rows can be intermingled. Use with

    caution on small static read only tables.

    Partitioned Tablespace - NUMPARTS 18

    Partitioned tablespaces allow only 1 table. Maximum

    number of partitions 254. Above 64 considered Large.

    T bl S S

  • 7/30/2019 DB2 Performance Primer_New

    21/33

    Table Space Scans

    Sequential I/O

    Random I/O

    SELECT PEAKNAME FROM PEAKS

    ORDER BY RATING;

    SELECT PEAKNAME FROM PEAKS

    WHERE STATE = CA AND RATING

    = MODERATE;

    AK

    CA

    CO

    WA

    LEGEND

    Buffer Manager initiates a GETPAGE request for P1 through P16.

    Buffer Manager initiates a GETPAGE request for P3 and P13.

    S ti l D t ti

  • 7/30/2019 DB2 Performance Primer_New

    22/33

    Sequential Detection

    20320 AK Mount McKinley

    14831 AK Mount Bear

    Page 50214494 CA Mount Whitney

    14420 CO Mount Harvard

    Page 503

    14410 WA Mount Rainier

    14270 CO Grays Peak

    Page 504

    14255 CO Longs Peak

    14196 CO Mount Yale

    Page 505

    14172 CO Mount Bross

    14110 CO Pikes Peak

    Page 506

    14080 CA Starlight Peak

    14059 CO Sunlight Peak

    Page 507

    14058 CA Split Mountain

    14037 CO Little Bear Peak

    Page 508

    14000 CA Thunderbolt Peak

    Page 501

    SELECT PEAKNAME

    FROM PEAKS

    WHERE STATE = CO;

    14005 CO Mount o/t Holy Cross

    p. 507p. 502 p. 503 p. 504 p. 505 p. 506 p. 508 p. 532

    SELECT PEAKNAME

    FROM PEAKS

    WHERE STATE = AK;

    p. 564p. 501 p. 502 p. 522 p. 542 p. 562 p. 566 p. 583

    ACTIVE

    6 out of 8

    NOT

    ACTIVE

    3 out of 8

    (data access sequential = 4 out of last 8 pages are page-sequential)

    1 1 1 1 1 1 24

    1 20 20 20 2 2 17

    p. 570

    p. 630

    38

    47

  • 7/30/2019 DB2 Performance Primer_New

    23/33

    Minimize Logging

    Default column placement from data model.

    Blue represents static columns that do not

    change once the row is created

    Purple represents column grouping updated

    associated to daily billing transactions

    Teal represents column grouping updated

    associated to monthly inventory transactions

    Dashed box represents variable data

    Adjusted column placement taking logging considerations into play.

    T i SQL

  • 7/30/2019 DB2 Performance Primer_New

    24/33

    Tuning SQL

    Tuning Steps

    Static and Dynamic SQL

    Get What You Need, Not What You Want

    Reoptimization

    Explain & Optimization Hints

  • 7/30/2019 DB2 Performance Primer_New

    25/33

    WHAT is Estimate & Select Access Path with Cheapest Estimated Cost

    Proper statistics can reduce the amount of SQLtuning required

    Lackluster statistics can be a Pandora's box! REBIND DATE < RUNSTATS DATE RUNSTATS performed yearly

    EXPLAIN(NO)

    Optimizer does not use Real Time Stats for access

    path selection Better filtering = fewer rows returned

  • 7/30/2019 DB2 Performance Primer_New

    26/33

    Get Only What You Need

    data manager

    relational data system

    filtered result set

    GETPAGE

    REQUEST

    BP3

    sort

    DBM1 Address Space

    buffer manger

    DSNDB07

    DASD

    SELECT * FROM TBL

    data manager

    relational data system

    filtered result set

    GETPAGE

    REQUEST

    BP3

    sort

    buffer manger

    DSNDB07

    DASD

    SELECT C5,C6,C7 FROM TBL

    P f M i t C t l

  • 7/30/2019 DB2 Performance Primer_New

    27/33

    Performance, Maintenance, Control

    ROLE ROLE DESCRIPTION0001 Database Ad ministrator

    0002 System Programmer

    0003 Application Programmer

    0004 Data Modeler

    EMP_ID ROLE PROJECT_1ST PROJECT_2ND77009134 0001 CLIENT REWRITE AGENT COMPENSATION

    77009134 0003 CUST RETENTION

    93989203 0002 AGENT COMPENSATION CUST RETENTION

    99080622 0004 CLIENT REWRITE CUST RETENTION

    DELETE RESTRICT

    IT_ROLE (parent) PROJECT_ROLE (child)

    EMP_ID ROLE PROJECT_1ST PROJECT_2ND

    77009134 Database Administrator CLIENT REWRITE AGENT COMPENSATION

    77009134 Application Programmer CUST RETENTION

    93989203 System Programmer AGENT COMPENSATION CUST RETENTION

    PROJECT_ROLE (column constraint)

    . DDL change to add a new role (data modeler)

    . DBA involvement needed for the table change

    . Better Performance, Tighter Control

    . Insert new row to add a new role (data modeler)

    . User, Programmer, or DBA can insert the row

    . Slower performance

    (DB2 RI)

  • 7/30/2019 DB2 Performance Primer_New

    28/33

    Getting Your Way

    REOPT(VARS) Useful when DB2s estimate of qualifying

    rows would benefit if the real host variablewas available to the optimizer at execution

    Evaluate data values at runtime

    Limit parts for partition scans

    Influence join sequence

    Reoptimization is done at open cursor Static SQL package level. Consider

    isolating/consolidating your reopt statementsto a few static packages.

    Dynamic SQL statement level. Moregranular and easier to invoke on a smallerscale.

    IFCID 0022 Did you get a better accesspath?

    Would static SQL benefit from being dynamicand taking advantage of dynamic cache?

    Sounds Great! Difficult to implement andmaintain.

    DSNZPARM change to activate

    Programmers should add QUERYNO to theircode.

    How are you going to name and manage youropthints? CHAR(8)

    After code has been bound with explain yes,need to update plan_table rows to add aOPTHINT.

    To return to the good access path you havepreviously established, you would rebind yourpackage with OPTHINT(ohstring).

    Verify hint is in use! SQL code +394,HINT_USED column of PLAN_TABLE, orQuery special register: CURRENT

    OPTIMIZATION HINT

    REOPTIMIZATION OPTIMIZATION HINTS

    A P h

  • 7/30/2019 DB2 Performance Primer_New

    29/33

    Access Paths

    More on QUERYNO = 103;

    DB2s Choices

    Understanding Predicates

    Small Tables in Memory

    Plan_Table Considerations

    ACCESSTYPE in Plan Table

  • 7/30/2019 DB2 Performance Primer_New

    30/33

    ACCESSTYPE in Plan Table

    RID = record identifier

    ACCESNAME

    R Table space scan, segmented tablespaceTable space scan, non-segmented tablespace

    Table space scan, partition scan (scanning limited parts)

    I mc=0 Non-matching index scan (scan of index leaf pages)One fetch index access (min/max)

    Perform 1 matching index scan for each value in (LIST)

    I1MATCHCOLS

    PREFETCHNM Multiple index scan (same index twice or two different indexes)MX Qualifying RIDs for each index used in multiple index scanMI AND predicate, intersection of the qualifying RIDs from each indexMU OR predicate, union of the qualifying RIDs from each index OPTHINT

    INDEXONLY

    PRIMARY_ACCESSTYPE

    D Direct row access via ROWID (page#, rid). One getpage!

    I mc>0 Matching index scan (using IX structure - root, non-leaf, leaf)

    P di t

  • 7/30/2019 DB2 Performance Primer_New

    31/33

    Predicates

    Know Your Predicates Indexable, matching predicates on index key columns

    Stage 1, not picked as matching but still refer to index columns

    (index screening)

    Stage 1, operating on a data page

    Stage 2, everything else

    Application Programming and SQL GuideTable 68, page 629, DB2 for OS/390 and z/OS V7

    PEAKS T bl

  • 7/30/2019 DB2 Performance Primer_New

    32/33

    Peak Name State Elevation Latitude Longitude Rating

    Mount McKinley AK 20320 630410N 1510013W VERY DIFFICULT

    Mount Bear AK 14831 611702N 1410832W MODERATE

    Mount Whitney CA 14494 363438N 1181733W MODERATE

    Mount Harvard CO 14420 385528N 1061912W EASY

    Mount Rainier WA 14410 465110N 1214531W DIFFICULT

    Grays Peak CO 14270 393802N 1054901W EASY

    Longs Peak CO 14255 401517N 1053655W MODERATE

    Mount Yale CO 14196 385039N 1061848W EASY

    Mount Bross CO 14172 392007N 1060625W EASY

    Pikes Peak CO 14110 385026N 1050238W EASY

    Starlight Peak CA 14080 370539N 1183119W EASY

    Sunlight Peak CO 14059 373738N 1073543W MODERATE

    Split Mountain CA 14058 370116N 1182520W MODERATE

    Little Bear Peak CO 14037 373400N 1052948W MODERATE

    Mount o/t Holy Cross CO 14005 392805N 1062845W EASY MODERATE

    Thunderbolt Peak CA 14000 370542N 1183124W EASY

    PEAKS Table

    Questions

  • 7/30/2019 DB2 Performance Primer_New

    33/33

    Questions...