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.

The second program, shown in Example 3-15, declares an ASENSITIVE SCROLLABLE<br />

cursor, which is the default in DECLARE CURSOR of V8. ASENSITIVE scrollable cursors<br />

allow <strong>DB2</strong> to choose the maximum sensitivity of a cursor as possible, and in this case the<br />

following SELECT statement does not indicate read-only cursor (that is, a UNION or UNION<br />

ALL, ORDER BY, FOR READ ONLY, FOR FETCH ONLY) so <strong>DB2</strong> determines dynamic as the<br />

maximum sensitivity.<br />

Example 3-15 Read program of dynamic cursor<br />

DECLARE C1 ASENSITIVE SCROLL CURSOR WITH HOLD FOR SELECT<br />

COL1, COL2, COL3, COL4, COL5,<br />

COL6, COL7, COL8, COL9, COL10<br />

FROM TABLE<br />

WHERE COL2 < ‘ROWNNNNNNNNN’;<br />

DO I = 1 TO 50000;<br />

FETCH NEXT C1 INTO<br />

:COL1,:COL2,:COL3,:COL4,:COL5,<br />

:COL6,:COL7,:COL8,:COL9,:COL10;<br />

END;<br />

The measurements have been done varying the number of FETCHes and the number of<br />

qualified rows opened as a cursor. This is done to show how the per<strong>for</strong>mance is affected by<br />

different result set sizes (the size of the temporary table in the case of the static cursor<br />

examples). The summary of our test cases is:<br />

► Use ISO(CS) and CD(NO) as a bind parameter<br />

For the read program these options provide maximum per<strong>for</strong>mance and concurrency.<br />

► 50k or 10 FETCHes<br />

► FETCH of 10 columns <strong>for</strong> a total of 50 bytes<br />

► Qualified 1 million or 100k rows opened as a cursor<br />

In the program shown in Example 3-17, we specified 1,000,000 or 100,000 in<br />

‘ROWnnnnnnnnn’ row-id.<br />

Table 3-4 shows the test results <strong>for</strong> static and dynamic cursors from the output of the <strong>DB2</strong> PE<br />

trace record.<br />

Table 3-4 Read cursor - Static vs. dynamic<br />

Trace data Static Dynamic<br />

Class 1<br />

ET/CPU<br />

Class 2<br />

ET/CPU<br />

Class 3<br />

suspend<br />

Fetch 50k<br />

Open 1M<br />

Fetch 10<br />

Open 1M<br />

Fetch 50k<br />

Open 100k<br />

Fetch 50k<br />

Open 1M<br />

Fetch 10<br />

Open 1M<br />

Fetch 50k<br />

Open 100k<br />

17.33/12.57 16.76/11.91 5.73 / 2.57 0.973/0.879 0.072/0.011 0.971/0.885<br />

17.21/12.44 16.75/11.90 5.61/ 2.43 0.849/0.743 0.069/0.009 0.849/0.748<br />

4.29 4.4 3.02 0.058 0.054 0.059<br />

Since the primary interest in this per<strong>for</strong>mance study is the <strong>DB2</strong> Class 2 CPU time and<br />

elapsed time, the PL/I programs were designed with minimum Class 1 (application) CPU and<br />

elapsed time in mind. There<strong>for</strong>e, the Class 1 CPU and elapsed times in all measurements is<br />

composed mainly of the <strong>DB2</strong> Class 2 CPU and elapsed times. The typical business<br />

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

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

Saved successfully!

Ooh no, something went wrong!