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.

FOR UPDATE OF COL6;<br />

FETCH SENSITIVE FIRST ROWSET FROM C1 FOR 25 ROWS INTO<br />

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

UPDATE TABLE SET COL6 = :COL6+10 WHERE CURRENT OF C1;<br />

DO I = 1 TO 39;<br />

FETCH SENSITIVE NEXT ROWSET FROM C1 INTO<br />

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

UPDATE TABLE SET COL6 = :COL6 +10 WHERE CURRENT OF C1;<br />

END;<br />

(Same <strong>for</strong> Deletes)<br />

Example 3-21 shows our multi-row FETCH and UPDATE program using a dynamic scrollable<br />

cursor.<br />

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

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

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

COL6 FROM TABLE<br />

WHERE COL2 < ‘ROWNNNNNNNNN’<br />

FOR UPDATE OF COL6;<br />

FETCH SENSITIVE FIRST ROWSET FROM C1 FOR 25 ROWS INTO<br />

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

UPDATE TABLE SET COL6 = :COL6+10 WHERE CURRENT OF C1;<br />

DO I = 1 TO 39;<br />

FETCH SENSITIVE NEXT ROWSET FROM C1 INTO<br />

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

UPDATE TABLE SET COL6 = :COL6 +10 WHERE CURRENT OF C1;<br />

END;<br />

(Same <strong>for</strong> Deletes)<br />

The summary of this test case is:<br />

► Use ISO (RS) as a bind parameter<br />

These options protect data integrity (not <strong>for</strong> per<strong>for</strong>mance).<br />

► 40 FETCHes followed by UPDATE on a rowset of 25 rows<br />

► 40 FETCHes followed by DELETE on a rowset of 25 rows<br />

► Qualified 1 million rows at open cursors<br />

Multi-row FETCH and UPDATE or DELETE with a static cursor<br />

We now move to the static updatable programs and apply multi-row update and delete<br />

function. The results are shown in Table 3-8. We can see the same per<strong>for</strong>mance apply to this<br />

type of program, the bulk of the per<strong>for</strong>mance overhead is attributable to the building of the<br />

temporary table, resulting in negligible differences in <strong>DB2</strong> class 2 elapsed and CPU times:<br />

16.43 vs. 16.39 and 11.49 vs. 11.44.<br />

Table 3-8 Multi-row FETCH and UPDATE or DELETE static<br />

Static single row<br />

UPDATE or<br />

DELETE 1k each<br />

Open 1M<br />

Class 1 ET / CPU 16.44 / 11.51 16.40 / 11.45<br />

Class 2 ET / CPU 16.43 / 11.49 16.39 / 11.44<br />

Class 3 suspend 4.50 4.51<br />

Static multi-row<br />

UPDATE or DELETE 25 rows<br />

x 40 times each<br />

Open 1M<br />

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

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

Saved successfully!

Ooh no, something went wrong!