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.

3.14.1 Per<strong>for</strong>mance<br />

In V8 you can code SQL statements easily in one query when multiple distinct operations<br />

need to be done <strong>for</strong> multiple columns be<strong>for</strong>e any column functions, such as AVG, COUNT, or<br />

SUM are applied. This multiple distinct enhancement in V8 benefits usability of SQL by<br />

reducing the amount of SQL statements or simplifying some queries. And it supports <strong>DB2</strong><br />

family compatibility by making it easier to move your programs to another plat<strong>for</strong>m.<br />

Per<strong>for</strong>mance improvements are experienced when the multiple SQL statements are merged<br />

into one.<br />

The purpose of these measurements is to evaluate the improvement you can get by using a<br />

single query statement specifying multiple DISTINCT keywords <strong>for</strong> multiple columns<br />

compared to the case of using several query statements, each with one DISTINCT keyword.<br />

In these tests we SELECT columns of all DECIMAL data and GROUP BY an indexed column.<br />

First we measure the following sequence of four SELECT statements per<strong>for</strong>ming only one<br />

SELECT COUNT(DISTINCT) <strong>for</strong> each one of the four columns (no buffer pool flush in<br />

between):<br />

1. SELECT COUNT(DISTINCT C1), C5 FROM T1 GROUP BY C5;<br />

2. SELECT COUNT(DISTINCT C2), C5 FROM T1 GROUP BY C5;<br />

3. SELECT COUNT(DISTINCT C3), C5 FROM T1 GROUP BY C5;<br />

4. SELECT COUNT(DISTINCT C4), C5 FROM T1 GROUP BY C5;<br />

Then we measure the per<strong>for</strong>mance of multiple distinct statements specifying more than one<br />

DISTINCT keyword. These are the alternatives in <strong>DB2</strong> V8 to the above SELECT statements.<br />

We have three cases of using multiple COUNT(DISTINCT) on two, three, and four columns:<br />

5. SELECT COUNT(DISTINCT C1), COUNT(DISTINCT C2), C5 FROM T1 GROUP BY C5;<br />

6. SELECT COUNT(DISTINCT C1), COUNT(DISTINCT C2), COUNT(DISTINCT C3), C5<br />

FROM T1 GROUP BY C5;<br />

7. SELECT COUNT(DISTINCT C1), COUNT(DISTINCT C2), COUNT(DISTINCT C3),<br />

COUNT(DISTINCT C4), C5 FROM T1 GROUP BY C5;<br />

Figure 3-46 shows the percentage of improvement with the multiple distinct statements<br />

compared to the total time of the single distinct statements. We are comparing the total time<br />

of test cases 1 and 2 with test case 5, the sum of 1, 2, and 3, to test case 6, and the sum of 1,<br />

2, 3, and 4, to test case 7.<br />

The results show the percentage of the reduction of class 2 elapsed time and CPU time by<br />

using multiple distincts. When we merge two SELECT single distinct statements into one<br />

multiple distinct statement, there is a 40% elapsed time reduction. When we merge four<br />

SELECT single distinct statements into one multiple distinct statement, we observe more than<br />

55% elapsed time reduction.<br />

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

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

Saved successfully!

Ooh no, something went wrong!