Home > AS/400 Tips > iSeries programmer tips > Improving OPNQRYF performance
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Improving OPNQRYF performance


David Moore
06.26.2001
Rating: -4.21- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


In an interactive session, enter STRDBG. Then run a CL containing the OPNQRYF that needs to be improved. What will happen is, the query optimizer will place messages into the job log that explain what actions it took to optimize the query. Also, it makes permanent performance recommendations.



Code

To view the messages generated after running the OPNQRYF with debug turned on, enter:

 WRKJOB
option 10 (display job log)
press PF10 (view detailed messages)
press PF18  (bottom - page up if needed)


Below is a sample:

For this OPNQRYF:

OPNQRYF    FILE((LIBRARY1/FILE1)) QRYSLT('CDSRSF = "Y"')                 


I received the following messages in the job log:

 All access paths were considered for file FILE1
 Additional access path reason codes were used.  
 Arrival sequence access was used for file FILE1
 Access path suggestion for file FDMCDP.    

Place your cursor on the ACCESS PATH SUGGESTION... message above and press PF1. It will give a detailed explanation as to permanent performance improvements, which can be made. Pressing PF1 on the messages above this one will provide you with a detailed explanation of what the query optimizer did. (see message output below)

Some additional hints for improving performance:

Determine if using the CHGQRYA command (in particular the DEGREE parameter) will have an impact on your query. Shops with SMP installed can see great improvements by adjusting this parameter.

Determine if changing the ALWCPYDTA parameter of the OPNQRYF command to see if changing the value will have an impact on your query.

Message ID . . . . . . : CPI432F Severity . . . . . . . : 00 Message type . . . . . : Information Date sent . . . . . . : 06/25/01 Time sent . . . . . . :

08:11:16

Message . . . . : Access path suggestion for file FILE1. Cause . . . . . : To improve performance the query optimizer is suggesting a permanent access path be built with the key fields it is recommending. The access path will access records from member FILE1 of file FILE1 in library LIBRARY1. In the list of key fields that follow, the query optimizer is recommending the first 1 key fields as primary key fields. The remaining key fields are considered secondary key fields and are listed in order of expected selectivity based on this query. Primary key fields are fields that significantly reduce the number of keys selected based on the corresponding selection predicate. Secondary key fields are fields that may or may not significantly reduce the number of keys selected. It is up to the user to determine the true selectivity of secondary key fields and to determine whether those key fields should be used when creating the access path. The query optimizer is able to perform key positioning over any combination of the primary key fields, plus one additional secondary key field. Therefore it is important that the first secondary key field be the most selective secondary key field. The query optimizer will use key selection with any remaining secondary key fields. While key selection is not as fast as key positioning it can still reduce the number of keys selected. Hence, secondary key fields that are fairly selective should be included. When building the access path all primary key fields should be specified first followed by the secondary key fields which are prioritized by selectivity. The following list contains the suggested primary and secondary key fields: CDSRSF. If file FILE1 in library LIBRARY1 is a logical file then the access path should be built over member FILE1 of physical file FILE1 in library LIBRARY1. Recovery . . . : If this query is run frequently, you may want to create the suggested access path for performance reasons. It is possible that the query optimizer will choose not to use the access path just created. For more information, refer to the DB2 for AS/400 SQL Programming book, SC41-5611, or the DB2 for AS/400 SQL Reference book, SC41-5612.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
iSeries programmer tips
Enhancing RPG with external SQL stored procedures
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
Implementing a browser interface in COBOL: Displaying database fields
Taking advantage of CL advancements, starting with V5R3
TAATOOL: Useful tools for programmers on IBM i
Implementing a browser interface in COBOL: Creating your graphic Web page
Implementing a browser interface in COBOL: Getting started
Making the most of RPG data handling on IBM i
Groovy programming on IBM i

RPG iSeries programming
Enhancing RPG with external SQL stored procedures
Introduction to SQLRPGLE on IBM i: Making a report
Making the most of RPG data handling on IBM i
IBM i shop boosts online sales with RPG-based Web platform
Migrating from RPG to EGL on IBM i
Allow access to data from a stored procedure result set using COBOL or RPG
EGL Rich UI on IBM i: Do you Dojo?
Programming for the Web on the IBM i, what is possible
A taste of COMMON: ILE, IBM releases, Web applications and new products
Documenting nested program structures on the AS/400

iSeries ILE programming
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
How to use an embedded SQL statement and display the result in a subfile
Eight steps for creating program documentation using AS/400 utilities
Searching fields for values
Searching part of a name or address in AS/400
Top 10 programmer tips YTD
How to use the binder language to manage service programs -- Part 3: Examples and pitfalls
Top 10 programmer tips of 2005
Understanding the binder language on AS/400

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Report Program Generator  (Search400.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts