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-13 Regrouping on MQT result<br />

In this example the populated MQT661 has 1808 rows as the result of joining two tables and<br />

grouping by BRN,PST. Explain was executed <strong>for</strong> query number 662 as shown in Example 3-5.<br />

Example 3-5 Explain <strong>for</strong> Q662<br />

** EXPLAIN ALL SET QUERYNO=662 FOR<br />

SELECT BRN, SUM(OFC),COUNT(DISTINCT PLC.POL),<br />

COUNT(COV.OFC)<br />

FROM COV,PLC<br />

WHERE<br />

COV.POL = PLC.POL AND COV.CVT='B'<br />

GROUP BY BRN<br />

ORDER BY BRN;<br />

The PLAN_TABLE <strong>for</strong> V8 in Figure 3-13 shows that the <strong>DB2</strong> Optimizer has selected the MQT.<br />

The result is a reduction in elapsed time from 45.1 sec. to 0.92 sec. We see a significant<br />

reduction even if we compare it with V7 with parallelism.<br />

The new access path using MQT regroups 1808 rows avoiding the nested loop join of one<br />

table having 1.7 million rows with a table with 624 thousand rows.<br />

Summary of measurements of a query rewrite <strong>for</strong> simple query:<br />

► V7 DEGREE(1)<br />

45.1 sec. elapsed time and 12.92 sec. CPU time<br />

► V7 DEGREE(ANY)<br />

9.04 sec. elapsed time and 13.87 sec. CPU time<br />

50 <strong>DB2</strong> <strong>UDB</strong> <strong>for</strong> z/<strong>OS</strong> <strong>Version</strong> 8 Per<strong>for</strong>mance <strong>Topics</strong><br />

Re-grouping on MQT results<br />

CREATE TABLE MQT661 (BRN,PST,COUNT,SUM) AS (<br />

SELECT BRN.PST,COUNT(DISTINCT PLC.POL),<br />

SUM(COV.OFC)<br />

FROM COV, PLC<br />

WHERE COV.POL=PLC.POL<br />

AND COV.CVT= 'B'<br />

GROUP BY BRN,PST)<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 />

1.7 M<br />

624 K<br />

COV<br />

PLC<br />

T<br />

T<br />

0<br />

1<br />

V8 PLAN_TABLE<br />

TNAME TABLE_TYPE METHOD<br />

MQT661 M 0<br />

1808 rows in MQT<br />

50<br />

40<br />

30<br />

20<br />

10<br />

0<br />

V7 degree=1<br />

V7 degree=any<br />

V8 using MQT<br />

47X<br />

Elapsed sec CPU sec<br />

117<br />

X

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

Saved successfully!

Ooh no, something went wrong!