fhg
Volume 10, Number 1 -- January 6, 2010

Let's Start Over With a New Beginning

Published: January 6, 2010

Hey, Ted:

I'm writing in response to your article Let's Start Over from the Beginning. Neither specifying CLOSQLCSR(*ENDMOD) nor running your program in a activation group *NEW (which is not even possible if your procedure is located in a service program and repeatedly called) is a good solution.

In both situations the open data path (ODP) will be deleted after execution and cannot be reused. That means each time you execute your query, the system performs a full open, which is a time-consuming process.

A full open is always necessary the first and second time a query is executed within the same activation group. When executing a full open, an access plan must be either created or validated. (If an access plan already exists, for example in the SQL plan cache or stored within the program object.) An access plan describes which indexes must be used, or whether a table scan or table probe must be executed, and also contains all information about any temporary objects, such as hash tables or relative record lists, that are necessary for executing the SQL statement.

After the access plan is generated or validated, the temporary objects will be created and filled with data (i.e., the ODP will be opened). Opening the ODP is the most time-consuming part of the optimization. After the first execution the ODP will be deleted. The next time the same query is executed, the already actualized access plan will be checked again and the ODP reopened. After the second execution the ODP stays open, which means for all subsequent executions, only the data within the temporary objects must be actualized.

When specifying CLOSQLCSR(*ENDMOD), the ODP will be deleted at the end of the module. That means each time you execute the same query--even within the same activation group--the access plan must be validated and the ODP must be recreated and cannot be reused.

If I tell my users that they will have to wait for half a minute the first time they call a program, but that subsequent calls will be faster, they will accept it. But my users will complain if they have to wait for 30 seconds each time they call the program.

The easiest way to solve Lynne's problem is to close the cursor before opening it. If the cursor is open, it will be closed. If it was not open, the system generated an error--SQLCODE -501 or SQLSTATE 24501--which can be checked and ignored.

In this way the ODP becomes reusable, and beginning with the third execution, only a soft (or pseudo) open is necessary, which means only the data must be actualized when opening the cursor.

--Birgitta Hauser


The following comes from the IBM i 6.1 Information Center:

The first time (or times) a open occurs for a specific statement in a job is a full open. A full open creates an Open Data Path (ODP) that will be then be used to fetch, update, delete, or insert rows. Since there will typically be many fetch, update, delete, or insert operations for an ODP, as much processing of the SQL statement as possible is done during the ODP creation so that same processing does not need to be done on each subsequent I/O operation. An ODP may be cached at close time so that if the SQL statement is run again during the job, the ODP will be reused. Such an open is called a pseudo open and is much less expensive than a full open. You can control the number of ODPs that are cached in the job and then number of times the same ODP for a statement should be created before caching it.

Thanks to Birgitta Hauser for starting off the new year with this valuable information. My answer to Lynne was just for her situation, and therefore too simplistic.

--Ted


RELATED STORY

Let's Start Over from the Beginning



                     Post this story to del.icio.us
               Post this story to Digg
    Post this story to Slashdot


Sponsored By
SEQUEL SOFTWARE

SEQUEL ViewPoint®--Data Access & Analysis
for Power Systems™ Servers

                                               · Easy to use by IT and end users
                                               · Automated data access and display
                                               · Complete BI package: reports, tables,key
                                                  performance indicators, and dashboards
                                               · IBM i-centric for real-time data analysis
                                               · Expert support and training
                                               · Secure data access
                                               · Green screen, Web, browser

SEQUEL--Fast, efficient & cost-effective data analysis

Click here for a FREE Information Kit!


Senior Technical Editor: Ted Holt
Technical Editor: Joe Hertvik
Contributing Technical Editors: Erwin Earley, Brian Kelly, Michael Sansoterra
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.

Sponsored Links

10ZiG Technology:  Ask us about our new Ethernet Terminal for only $195!
Bytware StandGuard Security:  Are you monitoring and auditing your System i security? FREE trial.
Manta Technologies:  Year-End SALE! 40% off the complete library and all combo packs. Ends Jan 15


 

IT Jungle Store Top Book Picks

Easy Steps to Internet Programming for AS/400, iSeries, and System i: List Price, $49.95
The iSeries Express Web Implementer's Guide: List Price, $49.95
The System i RPG & RPG IV Tutorial and Lab Exercises: List Price, $59.95
The System i Pocket RPG & RPG IV Guide: List Price, $69.95
The iSeries Pocket Database Guide: List Price, $59.00
The iSeries Pocket SQL Guide: List Price, $59.00
The iSeries Pocket Query Guide: List Price, $49.00
The iSeries Pocket WebFacing Primer: List Price, $39.00
Migrating to WebSphere Express for iSeries: List Price, $49.00
Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
Getting Started with WebSphere Express for iSeries: List Price, $49.00
Can the AS/400 Survive IBM?: List Price, $49.00
Chip Wars: List Price, $29.95


 
The Four Hundred
Power Systems i: The Windows Conundrum

Maintenance Contract Reduction a Good Resolution for 2010

CCSS Offers Flexible Pricing for Service Providers

Mad Dog 21/21: If Trees Were Free, Would the Press Be?

Ten Practices for 2010 Your CFO Will Love

Four Hundred Stuff
Datawatch Yields BI Gems from Existing Reports

GoFaster Governor Buster Marketed, With Discretion

Shield's FTP Client Addresses Problems with CCSID Configurations

Quadrant Bolsters Time Zone Support in FastFax

Linoma Joins iManifest U.S. to Help Spread the i Word

Four Hundred Monitor
Four Hundred Monitor's
Full iSeries Events Calendar

System i PTF Guide
January 2, 2010: Volume 12, Number 01

December 26, 2009: Volume 11, Number 52

December 19, 2009: Volume 11, Number 51

December 12, 2009: Volume 11, Number 50

December 5, 2009: Volume 11, Number 49

November 28, 2009: Volume 11, Number 48

TPM at The Register
US companies look to add jobs in 2010

3PAR bounces on takeover chatter

SGI inks deal for Tasmanian cluster

Oracle sniffing around Citrix, HP around Rambus

Novell stacks Linux and Mono for mainframes

3Com profit bump surprises Street

Pair plead not guilty to Galleon insider trading charges

Red Hat has a jolly Q3

AMD revs up Stream SDK

IT recession is no more, says study

Red Hat pulls plug on Itanium with RHEL 6

Shuttleworth steps down as Canonical CEO

THIS ISSUE SPONSORED BY:

SEQUEL Software
WorksRight Software
System i Developer


Printer Friendly Version


TABLE OF CONTENTS
Let's Start Over With a New Beginning

A Helpful Tool for Dealing with Unexpected Problems

Admin Alert: Upgrading a 550 to a 520 with V5R4?

Four Hundred Guru

BACK ISSUES




 
Subscription Information:
You can unsubscribe, change your email address, or sign up for any of IT Jungle's free e-newsletters through our Web site at http://www.itjungle.com/sub/subscribe.html.

Copyright © 1996-2010 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement