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.

Single row vs. multi-row FETCH<br />

To test multi-row FETCH in static and dynamic scrollable cursors, we used two PL/I programs.<br />

BIND options and sensitivity options <strong>for</strong> the DECLARE CURSOR and FETCH statements are<br />

kept the same as the single row read cursor program. Each of the multi-row read programs<br />

fetches 100 rows (the row set size) with a single fetch and per<strong>for</strong>ms a total of 500 fetches to<br />

be compared against the original read program doing 50,000 individual fetches.<br />

Example 3-18 shows a sample of our program <strong>for</strong> multi-row FETCH using a static scrollable<br />

cursor.<br />

Example 3-18 Multi-row FETCH program of a static scrollable cursor<br />

DECLARE C1 INSENSITIVE SCROLL CURSOR WITH ROWSET P<strong>OS</strong>ITIONING WITH HOLD FOR SELECT<br />

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

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

FROM TABLE<br />

WHERE COL2 < ‘ROWNNNNNNNNN’;<br />

FETCH INSENSITIVE FIRST ROWSET FROM C1 FOR 100 ROWS INTO<br />

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

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

DO I = 1 TO 499;<br />

FETCH INSENSITIVE NEXT ROWSET<br />

C1 INTO<br />

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

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

END;<br />

Example 3-19 shows a sample of our program <strong>for</strong> multi-row FETCH using a dynamic<br />

scrollable cursor.<br />

Example 3-19 Multi-row FETCH program of a dynamic scrollable cursor<br />

DECLARE C1 ASENSITIVE SCROLL CURSOR WITH ROWSET P<strong>OS</strong>ITIONING WITH HOLD FOR SELECT<br />

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

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

FROM TABLE<br />

WHERE COL2 < ‘ROWNNNNNNNNN’;<br />

FETCH FIRST ROWSET FROM C1 FOR<br />

100 ROWS INTO<br />

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

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

DO I = 1 TO 499;<br />

FETCH NEXT ROWSET<br />

C1 INTO<br />

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

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

END;<br />

In this test case we have not measured a different number of FETCHes or a different number<br />

of qualified rows, because the purpose of this case is the comparison of multi-row FETCH<br />

with single row FETCH. The summary of this test case is:<br />

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

These options provide maximum per<strong>for</strong>mance and concurrency <strong>for</strong> read programs.<br />

► 100 rows (rowset) of 500 FETCHes<br />

► Qualified 1 million at open cursor<br />

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

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

Saved successfully!

Ooh no, something went wrong!