You are on page 1of 36

Harjindersingh Mistry - DB2 SQL Query Compi er !

eam" India So#t$are La%" Banga ore

DB2 SQL Query Tuning

2012 IBM Corporation

Agenda

Systemati& step-%y-step approa&h #or 'uery-tuning (arious e)amp es

2012 IBM Corporation

List of Useful Diagnostic Tools

+or &o e&ting e)p ain in#ormation Se&tion e)p ain +or #ormatting e)p ain in#ormation d%2e)#mt +or monitoring 'uery e)e&ution d%2pd d%2top d%2 snapshots d%2 SQL monitoring #un&tions Se&tion a&tua s

2012 IBM Corporation

General Query Tuning Approach

Step 1- !a.e a 'ui&. o/er/ie$ o# 'uery and en/ironment Step 2- Che&. optimi0er1s &ardina ity estimations Step *- Che&. a&&ess-method and2or join-method o# most y e)pensi/e operation

2012 IBM Corporation

General Query Tuning Approach

Step 1- !a.e a 'ui&. o/er/ie$ o# 'uery and en/ironment 4nderstand the origina statement and optiona y optimi0ed statement #rom d%2e)#mt output

Loo. at the g o%a settings i.e %u##er-poo " sort-heap" optimi0ation- e/e et&5

Loo. at the o%je&ts used in the 'uery and &he&. i# there are signs o# poor maintenan&e2design e5g5 e)istan&e o# o/er# o$ re&ords

2012 IBM Corporation

General Query Tuning Approach

Step 2- Che&. optimi0er1s &ardina ity estimations 7n&e the 'uery and en/ironment are #ound to %e o." then &he&. #or &ardina ity estimations5

!his is the most important step5 It re'uires .no$ edge a%out under ying data5

Loo. #or &ardina ity underestimation1s & ue- sma num%ers ess than 1 i.e *500389e-03

Can those sma num%er ha/e a %ig impa&t : e5g5 is that sma num%er on the outer side o# ;L<7I; operation and inner side is a %ig ta% e :

I# the &ardina ity underestimation &an ha/e a %ig impa&t" then &on#irm the a&tua num%er o# re&ords %y using se&tion a&tua s5

7n&e" it is &on#irmed that optimi0er had underestimated &ardina ity" then ana y0e the re e/ant predi&ates and &orresponding data5

In most o# the &ases" &o e&ting additiona statisti&s reso /es the issue5

!hese additiona statisti&s are statisti&a /ie$ and &o umn group statisti&s5 More on them is des&ri%ed /ia e)amp es ater5

6 2012 IBM Corporation

General Query Tuning Approach

Step *- Che&. a&&ess-method and2or join-method o# most y e)pensi/e operation 7n&e the &ardina ity estmations are #ound to %e o." then oo. #or opportunities o# redu&ing the &ost o# 'uery e)e&ution5

+irst" o&ate the most e)pensi/e operation in the e)p ain p an5

In most o# the &ases" inde)ing and2or partitioning strategies reso /e the issue5

More on inde)ing and partitioning is des&ri%ed /ia e)amp es ater5

2012 IBM Corporation

Example !U"STATS
> 'uery is per#orming poor y on their produ&tion system &ompare to de/e opment system5

7rigina Statement-

-- Note: VW is a view select * from db2inst1.vw v, db2inst1.t1 t1 where v.x = t1.x SELECT ... FROM DB2INST1.T4 AS Q1, DB2INST1.T3 AS Q2, DB2INST1.T2 AS Q3, DB2INST1.T1 AS Q4 WHERE (Q1.T2ID = Q2.T2ID) AND (Q3.T4ID = Q1.T4ID) AND (Q1.Y = 'Y') AND (Q1.Z = 'N') AND (Q3.X = Q4.X) AND (Q3.Y IS NULL )

7ptimi0ed Statement-

2012 IBM Corporation

Example !U"STATS

9.906 NLJOIN ( 2) 11476.2 2892 /--------------+--------------\ 247.66 0.04 NLJOIN FETCH ( 3) ( 8) 11333.4 100.125 2888 4.00412 /---------+--------\ /---+--\ 0.0033 74416 1 712084 NLJOIN TBSCAN IXSCAN TABLE: DB2INST1 ( 4) ( 7) ( 9) T2 0.0199984 11333.4 75.0188 52 2888 3 /-------+------\ | | NOTE>> 0.0208 0.16 74416 712084 IXSCAN IXSCAN TABLE: DB2INST1 INDEX: DB2INST1 ( 5) ( 6) T1 IDX_1 0.0104877 0.00951078 0 1 | | 13 100 INDEX: DB2INST1 INDEX: DB2INST1 IDX_T4 IDX_T3

>&&ess p an-

2012 IBM Corporation

Example !U"STATS

C74;!?@A 'ueries to &on#irm the a&tua &ounts


SELECT COUNT(*) FROM "DB2INST1 "."T4"; RESULT: 13 ROWS SELECT COUNT(*) FROM "DB2INST1 "."T4" AS Q1 WHERE (Q1.Y = 'Y') AND (Q1.Z = 'N'); RESULT: 13 ROWS

B)tended diagnosti& in#ormation


1 EXP0045W. The table named "DB2INST1.T4" has fabricated statistics. This can lead to poor cardinality and predicate filtering estimates. The size of the table changed significantly since the last time the RUNSTATS command was run.

Diagnostic Identifier: Diagnostic Details:

So ution- Co e&t statisti&s %y running C4;S!>!S on the ta% e DB2I;S!15!,

10

2012 IBM Corporation

Example !U"STATS

>&&ess p an a#ter C4;S!>!S is e)e&uted ;ote IDSC>;?=A


6191.41 HSJOIN ( 2) 11948.8 2892 /--------------------+-------------------\ 74416 2.08 NLJOIN HSJOIN ( 3) ( 7) 11945.4 0.0277668 2892 0 /------+------\ /-------+------\ 74416 1 13 4 TBSCAN FETCH IXSCAN IXSCAN ( 4) ( 5) ( 8) ( 9) 11333.4 100.125 0.0156447 0.0112472 2888 4.00412 0 0 | /---+---\ | | 74416 1 712084 13 4 TABLE: DB2INST1 IXSCAN TABLE: DB2INST1 INDEX: DB2INST1 INDEX: DB2INST1 T1 ( 6) T2 IDX_T4 IDX_T3 75.0188 3 | 712084 INDEX: DB2INST1 IDX_1

11

2012 IBM Corporation

Example Statistical #ie$


> 'uery per#orman&e is poor5 !he CE4 &onsumption is high5 !here $as no major &hange either in system or app i&ation5

Query-

select i_item_id, i_item_desc, s_state, count(ss_quantity) as store_sales_quantitycount, avg(ss_quantity) as store_sales_quantityave, stddev(ss_quantity) as store_sales_quantitystdev, stddev(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov, count(sr_return_quantity) as_store_returns_quantitycount, avg(sr_return_quantity) as_store_returns_quantityave, stddev(sr_return_quantity) as_store_returns_quantitystdev, stddev(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov, count(cs_quantity) as catalog_sales_quantitycount, avg(cs_quantity) as catalog_sales_quantityave, stddev(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitystdev, stddev(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov from store_sales, store_returns, catalog_sales, date_dim d1, date_dim d2, date_dim d3, where d1.d_quarter_name = '2001Q1' and d1.d_date_sk = ss_sold_date_sk and i_item_sk = ss_item_sk and s_store_sk = ss_store_sk and ss_customer_sk = sr_customer_sk and ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number and sr_returned_date_sk = d2.d_date_sk and d2.d_quarter_name in ('2001Q1', '2001Q2', '2001Q3') and sr_customer_sk = cs_bill_customer_sk and sr_item_sk = cs_item_sk and cs_sold_date_sk = d3.d_date_sk and d3.d_quarter_name in ('2001Q1', '2001Q2', '2001Q3') group by i_item_id, i_item_desc, s_state order by i_item_id, i_item_desc, s_state fetch first 100 rows only

store,

item

12

2012 IBM Corporation

Example Statistical #ie$

>&&ess p an ? snippet A;ote the sma num%ers in ;L<7I;?9A and ;L<7I;?10A !his is a & ue #or a possi%i ity o# &ardina ity underestimation5

>s there are ;L<7I;s in/o /ed and %ig #a&t ta% es are in the inner" et us &he&. the a&tua &ardina ity5

... 1.38112e-05 ^NLJOIN ( 9) 30963 13550.8 /---------------------+----------------------\ 0.0113066 0.00122151 ^NLJOIN FETCH ( 10) ( 16) 30949.4 20.3389 13548.8 3 /--------------+--------------\ /---+----\ 1053.61 1.07313e-05 1 73049 ^HSJOIN FETCH IXSCAN TABLE: HARMISTR ( 11) ( 14) ( 17) DATE_DIM 9536.15 20.3465 13.5662 Q9 10388 3 2 /-----+------\ /---+----\ | 287514 267.691 1 2.8804e+06 73049 TBSCAN TBSCAN IXSCAN TABLE: HARMISTR INDEX: SYSIBM ( 12) ( 13) ( 15) STORE_SALES SQL131219050845050 7121.4 2388.85 13.5738 Q12 Q9 7776 2612 2 | | | 287514 73049 2.8804e+06 TABLE: HARMISTR TABLE: HARMISTR INDEX: SYSIBM STORE_RETURNS DATE_DIM SQL131219050957440 Q11 Q8 Q12
1* 2012 IBM Corporation

Example Statistical #ie$

>&tua &ardina ity-

Rows Rows Actual RETURN ( 1) Cost I/O | ... 1.38112e-05 5958 ^NLJOIN ( 9) 30963 NA /---------------------+----------------------\ 0.0113066 0.00122151 30229 0.197096 ^NLJOIN FETCH ( 10) ( 16) 30949.4 20.3389 NA NA /--------------+--------------\ /---+----\ 1053.61 1.07313e-05 1 73049 40686 0.742983 0.976943 NA ^HSJOIN FETCH IXSCAN TABLE: HARMISTR ( 11) ( 14) ( 17) DATE_DIM 9536.15 20.3465 13.5662 Q9 NA NA NA /-----+------\ /---+----\ | 287514 267.691 1 2.8804e+06 73049 287514 274 1 NA NA TBSCAN TBSCAN IXSCAN TABLE: HARMISTR INDEX: SYSIBM ( 12) ( 13) ( 15) STORE_SALES SQL131219050845050 7121.4 2388.85 13.5738 Q12 Q9 NA NA NA | | | 287514 73049 2.8804e+06 NA NA NA TABLE: HARMISTR TABLE: HARMISTR INDEX: SYSIBM STORE_RETURNS DATE_DIM SQL131219050957440 Q11 Q8 Q12
1, 2012 IBM Corporation

Example Statistical #ie$

Eredi&ates in/o /ed

!BSC>;?1*A is app ying o&a predi&ateHS<7I;?11A is app ying join predi&ate-

Q8.D_QUARTER_NAME IN ('2001Q1', '2001Q2', '2001Q3') (Q11.SR_RETURNED_DATE_SK = Q8.D_DATE_SK)

It seems that majority o# 'ua i#ied #a&t ta% e ro$s re#er to /ery sma #ra&tion o# dimension ta% e5

> statisti&a /ie$ shou d he p in this &ase5

So ution- Create a statisti&a /ie$ on ta% es S!7CBFCB!4C;S and D>!BFDIM5


create view sv_store_returns_date_dim as (select Q8.* from HARMISTR.DATE_DIM as Q8, HARMISTR.STORE_RETURNS as Q11 where Q11.SR_RETURNED_DATE_SK = Q8.D_DATE_SK); alter view harmistr.sv_store_returns_date_dim enable query optimization; runstats on view harmistr.sv_store_returns_date_dim tablesample bernoulli(10);

In the same $ay" $e shou d &reate statisti&a /ie$ #or S!7CBFS>LBS and D>!BFDIM as $e as C>!>L7GFS>LBS and D>!BFDIM5

13 2012 IBM Corporation

Statistical #ie$

Let us ta.e a /ery simp e e)amp e to %etter understand statisti&a /ie$


Table:T2 Y --A A A A A B D E F I

Table:T1 X Y -------1 A 2 B 2 C 4 D 7 E 7 F 7 G 7 H 9 I 9 J

Distribution of values in column T1.X TYPE SEQNO COLVALUE VALCOUNT -------------------------------------F 1 7 4 F 2 9 2 F 3 2 2

Consider the #o o$ing 'uery- SELECT

* FROM T1, T2 WHERE T1.Y = T2.Y

Distribution of values in column T1.X, after join TYPE SEQNO COLVALUE VALCOUNT -------------------------------------F 1 1 5 F 2 7 2
16 2012 IBM Corporation

Statistical #ie$

SELECT * FROM T1, T2 WHERE T1.Y = T2.Y AND T1.X=1

;o$" &onsider the #o o$ing 'uery-

Hithout statisti&a /ie$" optimi0er $i estimate &ardina ity o# this 'uery I 1" %ut the &orre&t /a ue is 3 J

18

2012 IBM Corporation

Example %olumn Group Stats

> 'uery1s per#orman&e is poor5 Query- 7rigina statement


SELECT ... FROM T1, T2, T3, T4 WHERE ... AND T1.ACCT_NUM = T2.ACCT_NUM AND T2.ACCT_NUM = T3.ACCT_NUM AND T2.ID_NUM = T3.ID_NUM AND T1.ACCT_NUM = T4.ACCT_NUM AND T1.REP_NUM = T4.REP_NUM AND T4.ACCT_NUM = T3.ACCT_NUM AND T4.ID_NUM = T3.ID_NUM AND T4.ACCT_IND = T3.ACCT_IND AND ('1800-01-01-00.00.00.000000' < T1.DATE_MOD) AND T1.COMM IN ('A', 'D') ...

1=

2012 IBM Corporation

Example %olumn Group Stats

>&&ess E an

55.8297 NLJOIN ( 2) 226198 66138.3 /------------+-----------\ 55.8297 1 NLJOIN FETCH ( 3) ( 10) 221047 92.2672 65932.4 3.68909 /----+---\ /---+---\ 57.0648 0.978356 3.05367 3.81189e+06 TBSCAN IXSCAN IXSCAN TABLE: DB2INST1 ( 4) ( 9) ( 11) T3 218193 50.0315 50.0303 65818.2 2 2 | | | 57.0648 1.06432e+06 3.81189e+06 SORT INDEX: DB2INST1 INDEX: DB2INST1 ( 5) T2_IDX T3_IDX 218193 65818.2 | 57.0648 <<< NOTE: Join of two big tables producing only 57 rows !!! HSJOIN ( 6) 218193 65818.2 /------+-----\ 6.69807e+06 1.15013e+06 TBSCAN TBSCAN ( 7) ( 8) 60191.6 33264.5 33540 17057 | | 6.69807e+06 3.3602e+06 TABLE: DB2INST1 TABLE: DB2INST1 T4 T1
2012 IBM Corporation

19

Example %olumn Group Stats

Eredi&ates app ied %y HS<7I;?6A(Q4.ACCT_NUM = Q1.ACCT_NUM) (Q1.REP_NUM = Q4.REP_NUM)

;ote that there are mu tip e e'ua ity join predi&ates %et$een these t$o ta% es5

!he optimi0er assumes that t$o predi&ates are independent o# ea&h other5 Ho$e/er" the &o umns &ou d %e statisti&a y &orre ated and that &ou d resu t in underestimation o# &ardina ity5

!his estimation is important %e&ause it is part o# ;L<7I;?*A1s outer side and that ;L<7I; has a %ig ta% e in its inner side5

So" et us &he&. the a&tua &ardina ity5

20

2012 IBM Corporation

Example %olumn Group Stats

>&tua &ardina ity


SELECT COUNT(*) FROM T4 AS Q1, T1 AS Q4 WHERE (Q1.REP_NUM = Q4.REP_NUM) AND (Q4.ACCT_NUM = Q1.ACCT_NUM) AND ('1800-01-01-00.00.00.000000' < Q4.DATE_MOD) AND Q4.COMM IN ('A', 'D'); RESULT: 1,155,273 rows

So ution- Co umn group statisti&s $i he p5

In this &ase" &o umns group statisti&s shou d %e &o e&ted on parent ta% e ? genera y the one $ith primary .ey A5

21

2012 IBM Corporation

Example %olumn Group Stats


!o #ind parent-&hi d re ationship %et$een t$o ta% es" &onsider the statisti&s o# join &o umns

Column ACCT_ NUM REP_ NUM

Table:T1 Colcard High2key Low2key Colcard 3357997 'JERE2' '00003' 3662064 32341 '95517' '63135' 36864

Table:T4 High2key Low2key 'V222S' '00003' '99999' '63135'

+rom these statisti&s" !, is the parent ta% e %e&ause C7LC>CD o# >CC!F;4M and CBEF;4M is greater than !11s respe&ti/e C7LC>CD statisti&s

the HIGH2KBL #or ea&h &o umn is greater and the L7H2KBL are the same

So" &o umn group statisti&s shou d %e &o e&ted on !, ta% e-

RUNSTATS ON TABLE DB2INST1.T4 ON ALL COLUMNS AND COLUMNS ((ACCT_NUM, REP_NUM)) WITH DISTRIBUTION AND SAMPLED DETAILED INDEXES ALL

22

2012 IBM Corporation

%olumn Group Stats

Let us ta.e a /ery simp e e)amp e to %etter understand &o umn group statisti&s5 Here" &ountry and &ity &o umns are &orre ated5

Country City Hotel Name -------------------------------------Germany Bremen Hilton Germany Bremen Best Western Germany Frankfurt InterCity Canada Toronto Four Seasons Canada Toronto Intercontinental WHERE Country = ? And City = ? With Independence : Selectivity = 1/2 * 1/3 = 0.1667

!he #o o$ing &o umn group statisti&s $i he p

RUNSTATS ON TABLE db2inst1.hotel ON ALL COLUMNS AND COLUMNS ( (country, city) ) WITH DISTRIBUTION AND SAMPLED DETAILED INDEXES ALL With Column Group Statistics : Selectivity = 0.3333

2*

2012 IBM Corporation

&perator %osts

!ypi&a y oo. #or the e)pensi/e operators re ati/e to the tota &ost Depending on the operator" there might %e di##erent possi%i ities

I# there seems nothing that you &an easi y do" &onsider the ne)t most e)pensi/e operator

Let us &onsider some operators in the ne)t #e$ s ides

2,

2012 IBM Corporation

'dentifying Expensi(e &perator

Cost is the num%er just %e o$ the operator num%er 7perator &ost is the in&rease in the &ost &ompared to the pre/ious operator ?or sum o# a input operator &ostsA Cost num%ers are &umu ati/e

3.00579e+6 >NLJOIN ( 10)

1.54341e+06
548903 /---------+---------\ 3.00579e+6 1 HSJOIN IXSCAN ( 11) ( 15) 1.23169e+06 311718 284686 0 /------+------\ | 215511 ! " ( 13) 1.07116e+06 181971 | 215511 !SCAN ( 14) 1317 IN#$X% &'SCH$&A I#X( !L() "5

1.01317e+07 !SCAN ( 12) 116551 93464 | 1.01317e+07 A!L$% &'SCH$&A !L($ "3

1.07016e+06
181971 | 215511 A!L$% &'SCH$&A !L(#

23

2012 IBM Corporation

Expensi(e Ta)le Scan


>re on y a #e$ &o umns needed : Inde) on y a&&ess possi% e : Eredi&ates #i ter signi#i&ant y : ISC>;M+B!CH may %e &heaper Consider Inde)es #or I; or 7C predi&ates Is this a #a&t ta% e $ith aggregation : Cou d $e de#ine a Materia i0ed Query !a% e Eartition" Eartition" Eartition Cou d it %e partitioned %y range : Cou d this %e a Mu ti-dimension C ustered ta% e : Both MDC N Cange partitioning :

26

2012 IBM Corporation

Example Expensi(e &! *redicate


Ero% em ?C1 I 3 >;D C2 I 10A 7C ?C1 I 6 >;D C2 I 12A Large ta% e s&an to #et&h a #e$ ro$s So ution Consider inde)es #or an Inde)-7ring p an
8

)$ CH ( 2) 230.236 6.9672

!SCAN ( 2) 3312.15 702 | 298854


A!L$% &'SCH$&A !I+ A!L$ "1

Be#ore
28

/----+----\ 8 298854 *I#SCN A!L$% &'SCH$&A ( 3) !I+ A!L$ 30.2756 "1 4 /-----+------\ 2 6 SO* SO* ( 4) ( 6) 15.138 15.138 2 2 | | 2 6 IXSCAN IXSCAN ( 5) ( 7) 15.1373 15.1373 2 2 | | 298854 298854 IN#$X% SA,,29 IN#$X% SA,,29 IN#X-0 IN#X-0 "1 "1

>#ter
2012 IBM Corporation

Example Expensi(e '" *redicate


Ero% em C1 I; ?105 100" 300" 10000A Large ta% e s&an to #et&h a #e$ ro$s So ution Consider an inde) $ith the &o umn +or e)amp e- inde) on ?C1" C*A Inde) ?C2" C1A is a so good i# the 'uery has an e'ua ity predi&ate on C2 8 !SCAN ( 2) 3312.15 702 | 298854
A!L$% &'SCH$&A !I+ A!L$ "1

8 NLJOIN ( 9)

122.22 16
/-----+-----\ 4 2 !SCAN )$ CH ( 10) ( 13) 0.014061 30.3206 0 4 | /----+----\ 4 2 298854 A!)NC% S'SI!& IXSCAN A!L$% &'SCH$&A +$N*O. ( 3) !I+ A!L$ "3 30.2756 "1 3 | 298854 IN#$X% SA,,29 IN#X-0 "1

Be#ore
2=

>#ter
2012 IBM Corporation

Expensi(e 'S%A" and +ET%,


+B!CH &ost is /ery high : List Ere#et&h p ans on the inner o# nested oop joins : Loo. at the CL4S!BCC>!I7 ?or CL4S!BC+>C!7CA I# it is not & ose to 100 ?or 1A" &onsider CB7CG against this inde) i# this is the .ey inde) used in most 'ueries Inde)-7n y >&&ess possi% e : I# good #i tering &ommon y used predi&ates are app ied at the +B!CH Consider adding the &o umn or &o umns to the inde)

29

2012 IBM Corporation

Expensi(e S&!T
Is there spi ing : Cou d you in&rease S7C!HB>E or B4++BCE77L : O do not in&rease S7C!HB>E too high i# there are &on&urrent Hash joins or sorts in this 'uery and spe&ia y in a mu ti-user en/ironment Cou d you &reate an inde) to a/oid the sort ;ote that an ISC>;-+B!CH may %e more e)pensi/e Eerhaps an inde)-on y a&&ess :

*0

2012 IBM Corporation

Example S&!T Spills


!he detai s #or a S7C! $i indi&ate i# the S7C! spi ed !he I27s indi&ate that there $as spi ing asso&iated $ith the S7C!5 Minimi0e spi s %y &onsidering inde)es and as dis&ussed ear ier" %y %a an&ing S7C!HB>E" SHB>E!HCBS and B4++BCE77L

SO* ( 16) 6.14826e+06 1.30119e+06 | 3.65665e+07 !SCAN ( 17) 2.00653e+06 1.14286e+06 | 3.74999e+07 A!L$% ,C#.O*#$*S

*1

2012 IBM Corporation

Expensi(e "ested Loop -oin


> !SC>; or S7C! on the inner shou d %e a/oided as #ar as possi% e Consider an inde) Consider CB7CG 7uter is arge and you ha/e an ISC>;-+B!CH on the inner : Consider Inde)-7n y a&&ess B)pression on join predi&ate : Cou d you a/oid the e)pression on the inner ta% e &o umn so that you &ou d use an inde) $ith start-stop .eys : Cou d you use generated &o umns $ith that e)pression :

*2

2012 IBM Corporation

Example A(oid S&!T on the inner of "L-&'"


33467.5

Ero% em PList-pre#et&hQ &hosen %e&ause o# poor & ustering So ution Inde)-7n y >&&ess CB7CG

NLJOIN

( 11) 15491.5 10529.4 /-----------+-----------\ 125.216 )$ CH ( 17) 55.7205 37.9624 /------+-----\ 125.216 3.16068e+08 *I#SCN #,- A!L$% &'SCH$&A ( 18) *ANS)AC 46.1653 "10 5.96244 | 125.216

267.277
! " ( 12) 884.75 376.972 | 13.3638 )$ CH ( 13) 884.666 376.972 /---+---\ 4686.66 18722 *I#SCN ( 14) 529.869 68 | 4686.66 SO* ( 15) 529.869 68 | 4686.66 IXSCAN ( 16) 528.787 A!L$% &'SCH$&A I&$#I& "9

SO*

( 19) 46.1651 5.96244 | 125.216 IXSCAN ( 20) 46.1508 5.96244 | 3.16068e+08 IN#$X% &'SCH$&A *ANS)AC (I#X "10
2012 IBM Corporation

**

Example Expensi(e %ommunication


Large !a% e Queues ?!QsA Consider rep i&ated dimension ta% es Cou d the arge dimension ta% e that is &ommon y joined %e partitioned the same $ay as the #a&t ta% e :
... 1.44527e+07 /NLJOIN ( 3) 9.04117e+08 8.98332e+07 /----+----\ 1.44527e+07 1 !SCAN ( 4) 761760 109515 | 1.44527e+07 #,- A!L$% ,C#S S O*$(SAL$S "4

I3456 S67e89:% ------------,876;6;<3 &84 I#% ,876;6;<3;3=% O56456 S67e89:% -------------,876;6;<3 &84 I#% ,876;6;<3;3=%

*,

! "0 1--( 5) 76.468 8 | 1 )$ CH ( 6) 18.7064 2 /---+----\ 1 266000 IXSCAN A!L$% ,C#S ( 7) C2S O&$* 10.4897 "2 ...

4 ( 0) S;3=>e N<?e (@ 3 (*$,L )

0) ,876;6;<3

2012 IBM Corporation

!eferences
1A Get the most out o# DB2 optimi0er http-22$$$5i%m5&om2de/e oper$or.s2data2 i%rary2te&harti& e2dm1023d%2a&&essp an2 2A 4nderstand &o umn group statisti&s in DB2http-22$$$5i%m5&om2de/e oper$or.s2data2 i%rary2te&harti& e2dm0612.apoor2inde)5htm

*3

2012 IBM Corporation

Than.s / ,appy ,olidays /

*6

2012 IBM Corporation