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.

► Reduced improvement when merge pass is still required<br />

► Reduced improvement when query has two or more parallel sort composites to be merged<br />

Multiple table GROUP BY sort<br />

Let us look at the query in Example 3-8 where <strong>DB2</strong> executes a parallel sort when grouping 4<br />

million rows in 600,000 groups in a join of two tables.<br />

Example 3-8 Multiple table GROUP BY sort query<br />

SELECT C_CUSTKEY, C_NAME,<br />

SUM(O_ORDERKEY * 0.0001) AS REVENUE,<br />

C_ACCTBAL, C_NAME, C_ADDRESS, C_PHONE, C_COMMENT<br />

FROM CUSTOMER, ORDER<br />

WHERE C_MKTSEGMENT = 'BUILDING'<br />

AND C_CUSTKEY = O_CUSTKEY<br />

AND O_ORDERDATE < DATE('1994-12-05')<br />

GROUP BY C_CUSTKEY, C_NAME,<br />

C_ACCTBAL, C_NAME, C_ADDRESS, C_PHONE, C_COMMENT<br />

Figure 3-35 shows the per<strong>for</strong>mance improvement.<br />

Multiple table GROUP BY sort<br />

Group By sort of 4M rows to 0.6M groups<br />

nested loop join of 2 tables, 1 parallel group, DEGREE(30)<br />

merge pass used <strong>for</strong> both V7 and V8<br />

up to 46% reduction in elapsed time<br />

no reduction in workfile activities<br />

Fetch first 10<br />

rows<br />

Figure 3-35 Multiple table group by sort<br />

Elapsed<br />

secs<br />

CPU<br />

secs<br />

Workfile<br />

getpages<br />

Fetch all rows Elapsed<br />

secs<br />

CPU<br />

secs<br />

Workfile<br />

getpages<br />

V7<br />

Seq Sort<br />

V8<br />

Parallel<br />

Sort<br />

We observe, in the example of GROUP BY, the best situation is when we fetch the first 10<br />

rows (reduction of 46% in elapsed time) when V8 is compared to V7.<br />

Multiple table ORDER BY sort<br />

Let us look at the query in Example 3-9 where the ORDER BY is requested.<br />

Delta<br />

54 29 -46%<br />

73 72.6 -0.5%<br />

195400 193610 -1%<br />

102 85 -17%<br />

120 124 +4%<br />

255108 253304 -0.7%<br />

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

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

Saved successfully!

Ooh no, something went wrong!