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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Increase of BIND cost<br />

BIND cost <strong>for</strong> query<br />

(select count(*)...)<br />

without MQT is 0.01 s<br />

BIND cost <strong>for</strong> query<br />

using one MQT is<br />

0.015 s<br />

Roughly 0.4 ms to<br />

examine each<br />

qualified MQT<br />

Figure 3-10 Increase of BIND cost<br />

We have run Explain <strong>for</strong> a simple query with varying number of MQTs (0, 1, 5, 10, 20, 30, and<br />

40) eligible <strong>for</strong> query rewrite. All MQTs are created the same except <strong>for</strong> the literal value in<br />

predicates. All MQTs are evaluated as possible candidates <strong>for</strong> query rewrite.<br />

We see that bind cost in CPU increases almost linearly as more and more MQTs are eligible<br />

<strong>for</strong> query rewrite.<br />

Query rewrite <strong>for</strong> a simple query<br />

Figure 3-11 reports the per<strong>for</strong>mance of a query rewrite <strong>for</strong> a simple query.<br />

This query selects the count of the number of rows grouped by column BRN <strong>for</strong> those values<br />

of BRNs that have more than 50 rows. In V7, <strong>DB2</strong> has to scan all rows from the source table<br />

(one million rows). The plan table indicates a table space scan <strong>for</strong> table EVE. <strong>DB2</strong> V7 could<br />

decrease the elapsed type if parallelism is enabled. With parallelism the elapsed time is<br />

smaller but there is a small increase in CPU time due to the parallelism overhead.<br />

When executing the same query in V8, the automatic query rewrite is done by the optimizer<br />

selecting the MQT named MQT091. This fact is reflected in the plan table showing a table<br />

scan in a smaller table space.<br />

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

► V7 DEGREE(1)<br />

24.77 sec. elapsed time and 4.06 sec. CPU time<br />

► V7 DEGREE(ANY)<br />

6.11 sec. elapsed time and 4.19 sec. CPU time<br />

► V8 using MQT<br />

1.1 sec. elapsed time and 0.06 sec. CPU time<br />

The measurements show that:<br />

CPU Time (sec)<br />

0.035<br />

0.03<br />

0.025<br />

0.02<br />

0.015<br />

0.01<br />

0.005<br />

BIND time<br />

0 1 5 10 20 30 40<br />

Number of MQT<br />

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

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

Saved successfully!

Ooh no, something went wrong!