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.

Multi-row FETCH with a static cursor<br />

We apply multi-row fetching to the read programs and check how much we can improve<br />

per<strong>for</strong>mance. The 50,000 individual fetch case (listed in Case 1 in Table 3-4 on page 99) is<br />

compared with a multi-fetch program that fetches 100 rows at a time 500 times (listed in<br />

Table 3-6).<br />

Since the 1 million row temporary table is built row by row, regardless of the fetch<br />

implementation, and since we learned that this activity takes up the majority of CPU cycles in<br />

the prior static cursor measurements (whether read or updatable programs), using the<br />

multi-fetch implementation has only improved the <strong>DB2</strong> class 2 CPU time by 3% (12.44 vs.<br />

12.05) and the <strong>DB2</strong> class 2 elapsed time by 2% (17.21 vs. 16.85).<br />

Table 3-6 Multi-row FETCH static<br />

Multi-row FETCH with a dynamic cursor<br />

The results of applying the same multi-fetch implementation to the dynamic cursor model are<br />

listed in Table 3-7. If we compare them to those of the 50,000 individual fetch program in<br />

Table 3-4 on page 99, Case 1, we see a large per<strong>for</strong>mance improvement. Both the <strong>DB2</strong> class<br />

2 elapsed time and CPU time have been cut in half: 0.743 vs. 0.340 and 0.849 vs. 0.426.<br />

Reducing the number of trips between the application and database engine by a factor of 100<br />

(50,000 fetches vs. 500 multi-fetches) accounts <strong>for</strong> the per<strong>for</strong>mance gains observed.<br />

Table 3-7 Multi-row FETCH dynamic<br />

Test scenario 4: Single row vs. multi-row FETCH & UPDATE or DELETE<br />

In this case we explored multi-row FETCH followed by UPDATE or DELETE. The multi-row<br />

write programs <strong>for</strong> update and delete use a row set size of 25 rows and per<strong>for</strong>m 40 fetches<br />

each. The multi-row updates or deletes are also per<strong>for</strong>med 25 rows at a time. So it is<br />

equivalent to 1,000 rows FETCHed and UPDATEd or DELETEd. We then compare it against<br />

single row FETCH and UPDATE or DELETE of 1,000 rows which was done as part of test<br />

scenario 2. Example 3-20 shows our multi-row FETCH and UPDATE program using a static<br />

scrollable cursor. Multi-row FETCH and DELETE programs are prepared similarly.<br />

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

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

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

COL5,COL6 FROM TABLE<br />

WHERE COL2 < ‘ROWNNNNNNNNN’<br />

104 <strong>DB2</strong> <strong>UDB</strong> <strong>for</strong> z/<strong>OS</strong> <strong>Version</strong> 8 Per<strong>for</strong>mance <strong>Topics</strong><br />

Static single row<br />

FETCH 50,000<br />

Open 1 million<br />

Class 1 ET / CPU 17.33 / 12.57 16.85 / 12.06<br />

Class 2 ET / CPU 17.21 / 12.44 16.84 / 12.05<br />

Class 3 suspend 4.29 4.34<br />

Static single row<br />

FETCH 50,000<br />

Open 1 million<br />

Class 1 ET / CPU 0.973 / 0.879 0.440 / 0.343<br />

Class 2 ET / CPU 0.849 / 0.743 0.426 / 0.340<br />

Class 3 suspend 0.058 0.064<br />

Static multi-row<br />

FETCH 100 rows 500 times<br />

Open 1 million<br />

Static multi-row<br />

FETCH 100 rows 500 times<br />

Open 1 million

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

Saved successfully!

Ooh no, something went wrong!