Your SlideShare is downloading. ×
V8 Multi-Row Fetch Podcast Series 2, Podcast 1
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

V8 Multi-Row Fetch Podcast Series 2, Podcast 1


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. V8 Multi-Row Fetch Podcast Series 2, Podcast 1 Susan Lawson Dan Luksetich YL&A
  • 2. Yevich, Lawson & Assoc. Inc. 2743 S. Veterans Pkwy PMB 226 Springfield, IL 62704 IBM is a registered trademark of International Business Machines Corporation. DB2 is a trademark of IBM Corp. © Copyright 2007, YL&A, All rights reserved. © YL&A 2007
  • 3. Disclaimer PLEASE READ THE FOLLOWING NOTICE The information contained in this presentation is based on techniques, algorithms, and documentation published by the several authors and companies, and in addition is the result of research. It is therefore subject to change at any time without notice or warning. The information contained in this presentation has not been submitted to any formal tests or review and is distributed on an “As is” basis without any warranty, either expressed or implied. The use of this information or the implementation of any of these techniques is a client responsibility and depends on the client’s ability to evaluate and integrate them into the client’s operational environment. While each item may have been reviewed for accuracy in a specific situation, there is no guarantee that the same or similar results will be obtained elsewhere. Clients attempting to adapt these techniques to their own environments do so at their own risks. Foils, handouts, and additional materials distributed as part of this presentation or seminar should be reviewed in their entirety. © YL&A 2007
  • 4. Multi-Row Fetch Ability to return multiple rows on a single API call – Potential performance improvement up to 50% Static or dynamic Scrollable or non-scrollable cursor support Wide Cursors – Multiple rows, instead of one Supports positioned UPDATE and DELETEs – But there are caveats Watch out for locks!! – Every row being processed by a multi-row fetch must be locked – Cursor is position on all rows in current rowset Locks will depend on isolation level and whether or not a result table is materialized Sample programs DSNTEP4 (which is DSNTEP2 with multi-row fetch) and DSNTIAUL also can exploit © YL&A 2007
  • 5. Multi-Row Fetch FETCH FETCH Block Fetch Mainframe DB2 DDF FETCH FETCH COBOL Address Address V7 V7 V7 V7 FETCH FETCH Program Space Space FETCH FETCH Network Client Block Fetch Mainframe Multi-row DB2 Multi-row DDF COBOL FETCH Address FETCH Address V8 V8 V8 V8 Program Space Space Network Client This requires This requires This happens automatically This happens automatically programming programming in compatibility mode (only in compatibility mode (only for fetch) No multi-row No multi-row for fetch) insert insert Multi-row fetch is specifically designed to save CPU support now support now – It is enabled for local application via specific SQL syntax for SQLJ, but for SQLJ, but Java – It is enabled for remote applications automatically Java batching may batching may For block fetching cursors help help Going across address spaces is expensive – If we get multiple rows in one operation we can save CPU © YL&A 2007
  • 6. Multi-Row Fetch and DDF Multi-row fetch will automatically be used for read-only queries using DDF – For example, a Java program using the Type 4 connection with Universal Driver Automatic use multi-row fetch when fetching rows from the table – While building the block to send to client – Cursor must be read only and CURRENTDATA NO with an non-ambiguous cursor (e.g. coded with FOR FETCH ONLY) – All block fetching against any V8 DB2 will use multi-row fetch to build the blocks Nothing has to be done by requestor or application – No host variable arrays needed – No requirement for FOR n ROWS – No effect on the blocking performed by DDF • Affects number of API calls between DDF and DBM1 – Can be an automatic instant CPU savings when moving from V7 to V8 CM © YL&A 2007
  • 7. Multi-Row Fetch Syntax DECLARE CUR1 CURSOR WITH ROWSET POSITIONING FOR SELECT COL1, COL2 FROM TABLE1; GET DIAGNOSTICS statement DIAGNOSTICS statement OPEN CUR1; can return individual row operation execution information FETCH NEXT ROWSET FROM CUR1 Fetch next rowset FOR :hv ROWS INTO :values1, :values2; and position in rowset Determines rowset size If not specified for a cursor with ROWSET POSITIONING then the size of the rowset is the same as the previous rowset fetch * You can adjust the rowset size… FETCH ROWSET FROM CUR1 Fetch 6 rows starting STARTING AT ABSOLUTE 10 FROM CUR from the 10th position FOR 6 ROWS INTO :values1, :values2; in the rowset © YL&A 2007
  • 8. Multi-Row Fetch - Impact Local Cobol Test Sequential Read of Approximately 39 Million Rows, 5 Columns CPU and Elapsed Times in Minutes 10 2 rows per fetch 9 (with diagnostics) 8 5 rows per fetch 7 10 rows per fetch 6 20 rows per fetch 5 50 rows per fetch 4 3 100 rows per fetch 2 1 row per fetch CPU 1 60% CPU 60% CPU Savings! Savings! Elapsed 0 © YL&A 2007
  • 9. Multi-Row Fetch - Impact Local Cobol Test 50,000 Random Read Requests at about 20 Rows Each Application is very dependent upon I/O response in a random application – No elapsed time improvement should be expected – Should get CPU improvement Actual result – One row fetch 592 seconds elapsed, 22.5 seconds CPU – Twenty row fetch 626 seconds elapsed, 16.7 seconds CPU – 25% CPU savings! Remote Application Remote clients – SQLJ client experienced no CPU increase when moved from V7 to V8. Multi-row fetch offset additional V8 CPU cost © YL&A 2007
  • 10. Courses by YL&A - Taught by skilled instructors world-wide! V8 for z/OS Transition – Application or DBA or both We customize all SQL (z/OS and LUW) classes based upon – Basic SQL customer requirements – Advanced and Complex SQL – SQL Performance Tuning and Optimization Application Development – Stored Procedure Development and Implementation – UDFs and Triggers Development Database Design ONLY YL&A offers you the DB2 V8 DBA Certification – Physical Design, Logical Design Crammer Course to Data Sharing help you become certified!! – Implementation, Performance, Recovery High Performance Design and Tuning – Application, Database, Systems DB2 z/OS V8 Certification Crammer Course © YL&A 2007
  • 11. CPU Reduction Through Performance Audits DB2 Performance Audits – Existing or new database designs and applications – Certification of design and implementation acceptance – Evaluation of all the performance ‘points’ in a DB2 environment Physical Design Subsystem Application Code and SQL – Help with bringing legacy application to an e-business environment – the rules have changed! What was acceptable performance in the past is NOT acceptable in an e-business environment – Experienced in ‘fighting fires’ – many performance problems do not become reality until production – Results: problems identified, solutions proposed (many implemented immediately), continual knowledge transfer during the process Cost Avoidance Through Performance Tuning!!!! © YL&A 2007
  • 12. Yevich, Lawson & Assoc. Inc. 2743 S. Veterans Pkwy PMB 226 Springfield, IL 62704 IBM is a registered trademark of International Business Machines Corporation. DB2 is a trademark of IBM Corp. © Copyright 2007, YL&A, All rights reserved. © YL&A 2007