Home > Store

DB2 SQL Tuning Tips for z/OS Developers

Register your product to gain access to bonus material or receive a coupon.

DB2 SQL Tuning Tips for z/OS Developers

eBook (Watermarked)

  • Your Price: $25.59
  • List Price: $31.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Description

  • Copyright 2013
  • Dimensions: 6" x 9"
  • Pages: 160
  • Edition: 1st
  • eBook (Watermarked)
  • ISBN-10: 0-13-303847-5
  • ISBN-13: 978-0-13-303847-7

The Definitive Solutions-Oriented Guide to IBM® DB2® for z/OS®: Now Fully Updated for Both v9 and v10!

The largest database tuning performance gains can often be obtained from tuning application code, and applications that use SQL to retrieve data are the best candidates for tuning. This well-organized, easy-to-understand reference brings together more than 100 SQL-related skills and techniques that any developer can use to build and optimize DB2 applications for consistently superior performance.

DB2 tuning expert Tony Andrews (“Tony the Tuner”) draws on more than 20 years of DB2-related experience, empowering you to take performance into your own hands, whether you’re writing new software or tuning existing systems. Tony shows you exactly how to clear bottlenecks, resolve problems, and improve both speed and reliability.

This book fully reflects the latest SQL programming best practices for DB2 V9 and DB2 V10 on z/OS: techniques that are taught in no other book and are rarely covered in general DB2 SQL courses. Drawing on his extensive consulting experience and highly praised training with Themis Inc., Tony also presents practical checklists and an invaluable 15-step methodology for optimizing virtually any DB2 application.

Coverage includes

  • Empowering developers on knowing what to do and where to look in resolving performance problems in queries or programs
  • Providing many programming and SQL coding examples
  • Establishing standards and guidelines that lead to high-performance SQL
  • Implementing time-efficient code walkthroughs to ensure that your standards are followed
  • Focusing on the small number of SQL statements that consume the most resources
  • Identifying simple solutions that deliver the most sizable benefits
  • Optimizing performance by rewriting query predicates more efficiently
  • Providing a better understanding of SQL optimization and Runstat statistics
  • Recognizing opportunities to tweak your code more effectively than the Optimizer
  • Optimizing SQL code with COBOL applications
  • Efficiently checking for the existence of data, rows, or tables
  • Using Runstats’ newest capabilities to consistently optimize paths to data

Sample Content

Table of Contents

CHAPTER 1  SQL Optimization Top 100+     1
1. Take Out Any/All Scalar Functions Coded on Columns in Predicates     2
2. Take Out Any/All Mathematics Coded on Columns in Predicates     3
3. Code Only the Columns Needed in the Select Portion of the SQL Statement     4
4. Stay Away from Distinct if Possible     4
5. Try Rewriting an In Subquery as an Exists Subquery     5
6. Always Make Sure Host Variables Are Defined to Match the Columns Datatype     6
7. Because Or Logic Can Be Problematic to the Optimizer, Try a Different Rewrite     6
8. Make Sure the Data Distribution and Other Statistics Are Good and Current in the Tables Being Processed     8
9. Use UNION ALL in Place of UNION Where Possible     9
10. Consider Hardcoding Versus Using a Host Variable     9
11. Minimize DB2’s SQL Requests     11
12. Try Rewriting Range Predicates as Between Predicates     12
13. Consider Using Global Temporary Tables     13
14. Give Prominence to Stage 1 over Stage 2 Predicates     14
15. Remember That the Order of (Some) Predicates Does Matter     15
16. Streamline Multiple Subqueries     16
17. Index Correlated Subqueries     17
18. Get to Know the DB2 Explain Tool     17
19. Use Tools for Monitoring     18
20. Employ Commit and Restart Strategies     19
21. Implement Good Index Design     19
22. Avoid Discrepancies with Non-Column Expressions     20
23. Begin with All Filtering Logic Outside Application Code     21
24. Ensure That Subquery Predicates Involving Min and Max Have the Possibility of Nulls Being Returned Handled     21
25. Always Code For Fetch Only or For Read Only with Cursor Processing When a Query Is Only Selecting Data     22
26. Avoid Selecting a Row from a Table to Help Decide Whether the Logic in the Code Should Execute an
Update or an Insert     23
27. Avoid Selecting a Row from a Table in Order to Get Values for an Update     23
28. Make Use of Dynamic SQL Statement Caching     23
29. Avoid Using Select *     24
30. Watch Out for Nullable Columns or Times When SQL Statements Could Have Nulls Returned from the Database Manager     25
31. Minimize the Number of Times Open and Close Cursors Are Executed     25
32. Avoid Not Logic in SQL     26
33. Use Correlation IDs for Better Readability     26
34. Keep Table and Index Files Healthy and Organized     27
35. Take Advantage of Update Where Current of Cursor and Delete Where Current of Cursor     27
36. When Using Cursors, Use ROWSET Positioning and Fetching Using Multiple-Row Fetch, Multiple-Row Update, and Multiple-Row Insert     28
37. Know the Locking Isolation Levels     28
38. Know Null Processing     30
39. Always Program with Performance in Mind     31
40. Let SQL Do the Work     32
41. Code with Lock Table     32
42. Consider OLTP Front-End Processing     33
43. Consider Using Dynamic Scrollable Cursors     34
44. Take Advantage of Materialized Query Tables to Improve Response Time (Dynamic SQL Only)     35
45. Insert with Select     37
46. Take Advantage of Multiple-Row Fetch     38
47. Take Advantage of Multiple-Row Insert     39
48. Take Advantage of Multiple-Row Update     40
49. Take Advantage of Multiple-Row Delete     42
50. Try Scalar Fullselects Within the Select Clause     42
51. Take Advantage of REOPT ONCE and REOPT AUTO in Dynamic SQL and REOPT VARS and REOPT ALWAYS in Static SQL     43
52. Identify Times for Volatile Tables     44
53. Use the ON COMMIT DROP Enhancement     45
54. Use Multiple Distincts     45
55. Take Advantage of Backward Index Scanning     46
56. Watch Out for the Like Statement     46
57. Set Your Clustering Index Correctly     47
58. Use Group By Expressions if Needed     48
59. Watch Out for Tablespace Scans     48
60. Do Not Ask for What You Already Know     49
61. Watch the Order of Tables in a Query     49
62. Use Left Outer Joins Over Right Outer Joins     51
63. Check for Non-Existence     51
64. Use Stored Procedures     52
65. Do Not Select a Column in Order to Sort on It     53
66. Always Limit the Result Set if Possible     53
67. Take Advantage of DB2 V8 Enhanced DISCARD Capabilities When It Comes to Mass Deletes     54
68. Take Advantage of the DB2 LOAD Utility for Mass Inserts     54
69. Watch Out for Materialization of Views, Nested Table Expressions, and Common Table Expressions     55
70. Consider Compressing Data     56
71. Consider Parallelism     57
72. Keep the STDDEV, STDDEV_SAMP, VAR, and VAR_SAMP Functions Apart from Other Functions     58
73. Consider Direct Row Access Using ROWID Datatype (V8) or RID Function (V9)     58
74. Test Your Queries with Realistic Statistics and a Level of Data to Reflect Performance Issues     60
75. Specify the Leading Index Columns in WHERE Clauses     61
76. Use WHERE Instead of HAVING for Filtering Whenever Possible     62
77. Keep in Mind Index Only Processing Whenever Possible     62
78. Index on Expression in DB2 V9     63
79. Consider the DB2 V9 Truncate Statement     64
80. Use DB2 V9 Fetch First and Order by Within Subqueries     65
81. Take Advantage of DB2 V9 Optimistic Locking     65
82. Use the DB2 V9 MERGE Statement     66
83. Understand the DB2 NOFOR Precompile Option     68
84. Consider Select Into Using Order By     69
85. Code Boolean Term Predicates Whenever Possible     69
86. Try Transitive Closure Coding    70
87. Avoid Sorts with Order By    71
88. Use Joins Instead of Subqueries Whenever Possible    71
89. Watch Out for Case Logic    71
90. Take Advantage of Functions in the Order By Clause    72
91. Know Your Version of DB2     72
92. Understand Date Arithmetic     73
93. Know Your High-Volume Insert Choices     73
94. Know About Skip Locked Data (V9) for Lock Avoidance. . . . . .75
95. Sort Your Input Streams     75
96. If You Need True Uniqueness, Try the V8 Generate_Unique Function     76
97. Know the New Options for Declared Temporary Tables     76
98. Watch Out When Executing Get Diagnostics     77
99. Order Your In List Appropriately     77
100. Update and Delete with Select (V9)     77
101. Execute SQL Statements Only if Necessary     78
102. Take Advantage of In-Memory Tables     78
103. Stay Away from Catchall SQL Statements     79
104. Avoid Unnecessary Sorting     79
105. Understand Expressions and Column Functions     79
106. Watch Out When Combining Predicates     80
107. Add Redundant Predicates to Search Queries     80
108. Take Advantage of Improved Dynamic Caching (V10)     81
109. Try Currently Committed for Lock Avoidance (V10)     82
110. Try System Temporal Tables for Historical Data (V10)     83
111. Try Business Temporal Tables for Historical Data (V10)     85
112. Know Your Ranking Functions (V10)     86
113. Take Advantage of Extended Indicators (V10)     87
114. Get Greater Timestamp Precision (V10)     88
115. Try Index Includes (V10)     89
116. Use With Return to Client (V10)     89
CHAPTER 2  DB2 SQL Hints     91
1. Try the Optimize for 1 Row Statement at the End of the SQL Statement     91
2. Add the A.PKEY = A.PKEY Predicate to the SQL Query, Where PKEY Equals the Primary Key Column of the Table     92
3. Disqualify an Index Choice     93
4. Change the Order of Table Processing     95
5. Use Distributed Dynamic SQL     96
CHAPTER 3  SQL Standards and Guidelines     99
For COBOL Developers     99
For All SQL Developers     102
CHAPTER 4  SQL Program Walkthroughs     107
CHAPTER 5  Existence Checking     111
Example 1     111
Example 2     113
CHAPTER 6  Runstats     115
CHAPTER 7  Initial Steps in Tuning a Query     117
APPENDIX A  Predicate Rewrite Examples     121
  Predicate Rewrites: Transitive Closure     122
APPENDIX B  DB2 SQL Terminology     125
Index     131

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020