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.

► V8 using MQT<br />

0.92 sec. elapsed time and 0.11 sec. CPU time<br />

The measurements show that the elapsed time was 49 times smaller (about 97%) and CPU<br />

time 117 times smaller (about 99%) when we compare V7 DEGREE(1) with V8 using an<br />

MQT.<br />

Expression derivation<br />

► Arithmetic expressions: (A+B)*C can be derived from B+A and C<br />

► Column equivalence: If TI.C1=T2.C1, T2.C1 can be used <strong>for</strong> T1.C1<br />

► Scalar functions: SUBSTR(A,3,5) can be derived from A<br />

► Set functions: AVG(C) can be derived from SUM(C) and COUNT(*) if C NOT NULL<br />

Figure 3-14 shows one example of expression derivation using an MQT.<br />

Expression derivation<br />

Query<br />

Figure 3-14 Expression® derivation example<br />

In the example the populated MQT673 is the result of joining three tables and two<br />

aggregations:<br />

SUM(COV.MCP),SUM(PLC.CAS)<br />

The measured query selects<br />

SUM(COV.MCP) + SUM(PLC.CAS)<br />

This can be derived from the two aggregated columns from MQT.<br />

The predicates<br />

SELECT<br />

CREATE TABLE MQT673 ( COUNT,SUM1,SUM2,CVT) AS(<br />

SELECT<br />

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

SUM(COV.MCP),SUM(PLC.CAS),<br />

COV.CVT<br />

FROM<br />

PLC,COV,EVE<br />

WHERE<br />

PLC.POL = EVE.POL AND<br />

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

EVE.EXT = 'ADD BILL' AND<br />

EVE.TXC = 'IBIA0102'<br />

GROUP BY COV.CVT)<br />

DATA INITIALLY DEFERRED..........<br />

COUNT(DISTINCT PLC.POL), MQT673 disabled <strong>for</strong> QR<br />

SUM(COV.MCP) + SUM(PLC.CAS) Query ran <strong>for</strong> 10.5 seconds<br />

FROM<br />

PLC,COV,EVE MQT673 enabled <strong>for</strong> QR<br />

WHERE Query ran <strong>for</strong> 0.91 second<br />

using<br />

PLC.POL = EVE.POL AND<br />

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

EVE.EXT = 'ADD BILL' AND EVE.TXC = 'IBIA0102' AND COV.CVT = 'P' ;<br />

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

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

Saved successfully!

Ooh no, something went wrong!