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.

DO I = 1 TO 1000;<br />

FETCH SENSITIVE NEXT C1 INTO<br />

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

:COL6;<br />

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

END;<br />

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

Example 3-17 shows the program of a dynamic scrollable cursor. This program specifies<br />

explicitly DYNAMIC cursor in DECLARE CURSOR because the program is <strong>for</strong> update or<br />

delete.<br />

Example 3-17 Update program of dynamic cursor<br />

DECLARE C1 SENSITIVE DYNAMIC SCROLL CURSOR WITH HOLD<br />

FOR SELECT<br />

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

COL6 FROM TABLE<br />

WHERE COL2 < ‘ROWNNNNNNNNN’<br />

FOR UPDATE OF COL6;<br />

DO I = 1 TO 1000;<br />

FETCH SENSITIVE NEXT C1 INTO<br />

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

:COL6;<br />

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

END;<br />

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

As in the previous test case, we now examine UPDATEs and DELETEs with different<br />

numbers of qualified rows. The summary description of this test case is:<br />

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

This option protects data integrity (not <strong>for</strong> per<strong>for</strong>mance).<br />

► 100k or 10 FETCHes followed by 100k or 10 UPDATEs<br />

► 100k or 10 FETCHes followed by 100k or 10 DELETEs<br />

► FETCH of 6 columns <strong>for</strong> a total of 37 bytes<br />

► Qualified 1 M or 50k rows opened as a cursor<br />

The trace record results <strong>for</strong> a static and dynamic updatable cursor are listed in Table 3-5.<br />

Table 3-5 Update 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 />

UPDATE<br />

or<br />

DELETE<br />

1k<br />

Open 1M<br />

UPDATE<br />

or<br />

DELETE<br />

10<br />

Open 1M<br />

UPDATE<br />

or<br />

DELETE<br />

1k<br />

Open 50k<br />

UPDATE<br />

or<br />

DELETE<br />

1k<br />

Open 1M<br />

UPDATE<br />

or<br />

DELETE<br />

10<br />

Open 1M<br />

UPDATE<br />

or<br />

DELETE<br />

1k<br />

Open 50k<br />

16.44/11.51 15.75/11.16 4.95 / 1.33 0.601/0.148 0.218/0.016 0.508/0.144<br />

16.43/11.49 15.75/11.16 4.93 / 1.32 0.589/0.135 0.215/0.014 0.496/0.131<br />

4.5 4.31 3.56 0.454 0.195 0.364<br />

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

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

Saved successfully!

Ooh no, something went wrong!