19.06.2013 Views

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

DB2 UDB for z/OS Version 8 Performance Topics - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 3-12 Query rewrite <strong>for</strong> join<br />

Query rewrite <strong>for</strong> join<br />

CREATE TABLE MQT201 (CRE,INT,COUNT) AS(<br />

SELECT CRE,INT,COUNT(*)<br />

FROM CLA,COI,CIA<br />

WHERE COI.POL=CIA.POL AND<br />

COI.CVI=CIA.CVI AND<br />

COI.CLI=CIA.CLI AND<br />

CIA.CLI=CLA.CLI AND<br />

CIA.CAI=CLA.CAI<br />

GROUP BY CRE,INT)<br />

DATA INITIALLY DEFERRED<br />

REFRESH DEFERRED<br />

MAINTAINED BY USER<br />

ENABLE QUERY OPTIMIZATION;<br />

V7 PLAN_TABLE<br />

TABLE<br />

SIZE<br />

TNAME TABLE_TYPE METHOD<br />

633 K<br />

1.5 M<br />

1.3 M<br />

COI<br />

CIA<br />

CLA<br />

V8 PLAN_TABLE<br />

T<br />

T<br />

T<br />

0<br />

1<br />

1<br />

TNAME TABLE_TYPE METHOD<br />

MQT201 M 0<br />

171 rows in MQT<br />

Elapsed sec CPU sec<br />

GROUP BY and predicate matching<br />

The MQT remains a candidate <strong>for</strong> query rewrite if the query GROUP BY clause results in a<br />

subset of the rows that are in the MQT<br />

The predicate in the query subsumes the predicate in the MQT. Example: C1>8 subsumes<br />

C1>0.<br />

The predicates in the query should be coded as those in the MQT subselect. Otherwise,<br />

matching may fail on some complex predicates.<br />

Figure 3-13 shows the impact of regrouping the MQT data when <strong>DB2</strong> obtains the final answer<br />

set in the query.<br />

30<br />

25<br />

20<br />

15<br />

10<br />

5<br />

0<br />

V7 DEGREE(1)<br />

V7 DEGREE(ANY)<br />

V8 using MQT<br />

31X<br />

236<br />

X<br />

Chapter 3. SQL per<strong>for</strong>mance 49

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!