fhg
Volume 7, Number 11 -- March 21, 2007

Reader Feedback on Using the SQL SET OPTION Statement

Published: March 21, 2007

Hey, Michael:

I just read your article about the SET OPTION statement. Here are some minor comments about the OPTION CLOSQLCSR. There is a difference between closing a SQL cursor with the SQL statements CLOSE or COMMIT and closing a cursor at either *ENDMOD or *ENDACTGRP (or the other options for non-ILE programs).

When closing a cursor with the SQL commands, only a soft (or pseudo) close will be performed, that is the ODP (if reusable) stays cached and will only be reactivated the next time the SQL statement will be executed.

Closing a cursor at the end of a module (*ENDMOD) or at the end of the activation group (*ENDACTGRP) will hard close the ODPs, that is, all temporary objects are deleted. When rerunning the same SQL statements, a complete full open must be performed. A full open includes among others: Index estimates, creating and validating access plans, creating the ODP based on the validated access plans. The creation of the ODP (i.e. temporary objects such as bitmaps or hash tables or temporary tables or indexes) is the most expensive process in the optimization. And each SQL statement gets its own ODP, which means that if the same statement is coded several times for each of these statements, then the complete optimization process must be performed.

The main goal to gain performance is, to minimize the full opens and hard closes. This can be achieved by a modular programming, where each SQL statement embedded in its own exported procedure and by avoiding the hard closing of cursors.

Instead of specifying *ENDMOD to be sure that the cursor really gets closed, it would be much better to execute the SQL statement CLOSE just before executing the OPEN statement or the PREPARE statement with dynamic SQL. If the cursor is already opened, it will be closed and with the next open the ODP can be reused. If the cursor is already closed, so much the better.

Form performance aspects, specifying *ENDMOD or using activation group *NEW should be avoided, the optimization process is too expensive! I can explain to my users that they have to wait for half a minute the first time they execute a program. They'll accept it, if all the subsequent executions will perform in less than 2 seconds. But I'll get into trouble if the users have to wait half a minute each time they call the program.

By the way, dynamic SQL also should be reduced as much as possible. With dynamic SQL the access plans always must be created from scratch when executing the statement. With static SQL on the other hand the access plans are stored and updated in the (service) program objects and only must be validated at run time. But it becomes better when the SQL statements can be executed by the SQL Query Engine, because these access plans get stored in the plan cache and can be used by all jobs.

Best regards,

--Birgitta Hauser, SSS-Software GmbH


Thanks, Birgitta. These comments are really helpful. We'll add a link to it at the bottom of the original article so people see it.

--Michael


RELATED STORY

Using the SQL SET OPTION Statement



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


Sponsored By
HELP/SYSTEMS

SEQUEL can be used for
virtually ALL business intelligence functions
on the System i, including:

                                                    · Executive Dashboards
                                                    · Graphical Query & Reporting
                                                    · Drill-Down Data Analysis
                                                    · Multi-Platform Database Support
                                                    · E-Mail Report and File Distribution
                                                    · Secure Web Access

SEQUEL is the single solution for all
your business intelligence needs.

www.helpsystems.com


Senior Technical Editor: Ted Holt
Technical Editors: Howard Arner, Joe Hertvik, Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Brian Kelly, Marc Logemann, David Morris
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

COMMON:  Join us at the 2007 conference, April 29 – May 3, in Anaheim, California
Databorough:  X-analysis is the world leader in AS/400 application retro-documentation
Patrick Townsend & Associates:  Alliance AES/400 - database field encryption


IT Jungle Store Top Book Picks

The System i Pocket RPG & RPG IV Guide: List Price, $69.95
The iSeries Pocket Database Guide: List Price, $59.00
The iSeries Pocket Developers' 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
iSeries Express Web Implementer's Guide: List Price, $59.00
Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
Getting Started with WebSphere Express for iSeries: List Price, $49.00
WebFacing Application Design and Development Guide: List Price, $55.00
Can the AS/400 Survive IBM?: List Price, $49.00
The All-Everything Machine: List Price, $29.95
Chip Wars: List Price, $29.95

 

The Four Hundred
IBM Pays for System i5 Video Viral Marketing

System i Shops Plenty Annoyed About Missing WDSc Features

It Was Inevitable: IBM Jacks Maintenance Fees on Midrange Gear

Mad Dog 21/21: The China Spin Drone

The Linux Beacon
Red Hat Integrates and Simplifies with RHEL 5

The Feeds and Speeds of Red Hat Enterprise Linux 5

Transaction Processing Council Launches TPC-E Benchmark

Mad Dog 21/21: The China Spin Drone

Four Hundred Stuff
Vision Committed to Developing ORION

Infor Advocates Open Approach to SOA

IBM to Distribute Info Builders' iSeries BI Tools

LANSA Puts RAMP to the Test

Big Iron
Putting the z in College Degrees

Top Mainframe Stories From Around the Web

Chats, Webinars, Seminars, Shows, and Other Happenings

System i PTF Guide
March 17, 2007: Volume 9, Number 11

March 10, 2007: Volume 9, Number 10

March 3, 2007: Volume 9, Number 9

February 24, 2007: Volume 9, Number 8

February 17, 2007: Volume 9, Number 7

February 10, 2007: Volume 9, Number 6

The Windows Observer
Windows Server 2003 SP2 Released by Microsoft

Microsoft Unveils 'Duet'-Like Interface, New ERP Releases

Intel Delivers Low-Power, Quad-Core Xeon Chips

VoIP's Future Rosy, Microsoft Biz Chief Says

The Unix Guardian
Intel Delivers Low-Power, Quad-Core Xeon Chips

Server Makers Have $5.3 Billion Bumper Crop in Q4 in Europe

Lawson Updates ERP, Unveils SaaS Plans at User Conference

As I See It: The Digital Life

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

THIS ISSUE SPONSORED BY:

Profound Logic Software
Help/Systems
WorksRight Software



TABLE OF CONTENTS
iSeries Navigator Job Monitor

Reader Feedback on Using the SQL SET OPTION Statement

Changing ODBC Sign-On Pop Up Values

Four Hundred Guru

BACK ISSUES

From the IT Jungle Forums
Compiler Directives and Control Specifications

PTF for WDSC 7.0

How to collect the object authorities in a PF

VARPG on Windows Server

Window subfile with another input capable record format





 
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-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement