• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Reader Feedback on Using the SQL SET OPTION Statement

    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

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Tags:

    Sponsored by
    Lightedge

    Your IBM Power Cloud Strategy Should Start With “Why?”

    Moving IBM i to the cloud isn’t just an infrastructure decision.

    A hardware refresh, data center exit, IBM i skills gap, disaster recovery requirement, or broader cloud initiative can each lead to a very different architecture.

    At Lightedge, we start by understanding what you’re trying to accomplish. Then we look at the workload, application dependencies, resiliency requirements, operating model, and long-term strategy to determine where that workload belongs.

    Managed IBM Power cloud? IBM Power Virtual Server? DR in the cloud? A hybrid architecture connecting IBM Power with AWS or Azure?

    There isn’t one right answer for every IBM i environment.

    Start with the business requirement. Understand the workload. Then decide where it belongs.

    Explore IBM Power cloud, managed services, and hybrid solutions from Lightedge.

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    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

    iSeries Navigator Job Monitor Changing ODBC Sign-On Pop Up Values

    Leave a ReplyCancel reply

Volume 7, Number 11 -- March 21, 2007
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

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • IBM i Delivers New Development Tooling With 2026 Fall Tech Refreshes
  • Big Blue Says AI Is Not Behind The Big Uptick In IBM i Security Alerts
  • Guru: Web Service With Pagination
  • The GenAI Revolution And Product Shortages Send IT Budgets Skyward
  • IBM i PTF Guide, Volume 28, Number 40
  • IBM i PTF Guide, Volume 28, Number 41
  • Bob Code Assistant Gets Better Understanding Of IBM i Applications
  • IBM i In The Cloud And The Case For Reversing Replication
  • Guru: From Hiking Boots To Long-Term Memory
  • Inside IBM’s New PowerHA Cloud Offering, Full System Manager

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle