Rough Cuts are manuscripts that are developed but not yet published, available through Safari. Rough Cuts provide you access to the very latest information on a given topic and offer you the opportunity to interact with the author to influence the final publication.
This is the Rough Cut version of the printed book.
The Definitive Solutions-Oriented Guide to IBM® DB2® for z/OS®: Now Fully Updated for Both v9 and v10!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&nbs
