DB2 UDB for Iseries Database Performance and Query Optimization

DB2 UDB for Iseries Database Performance and Query Optimization

ERserver iSeries DB2 Universal Database for iSeries - Database Performance and Query Optimization ER s er ver iSeries DB2 Universal Database for iSeries - Database Performance and Query Optimization © Copyright International Business Machines Corporation 2000, 2001, 2002. All rights reserved. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About DB2 UDB for iSeries Database Performance and Query Optimization .........vii Who should read the Database Performance and Query Optimization book ...........vii Assumptions relating to SQL statement examples ...................viii How to interpret syntax diagrams .........................viii What’s new for V5R2 ...............................ix || Code disclaimer information .............................ix Chapter 1. Database performance and query optimization: Overview ............1 Creating queries .................................2 Chapter 2. Data access on DB2 UDB for iSeries: data access paths and methods .......3 Table scan ...................................3 Index .....................................3 Encoded vector index ...............................3 Data access: data access methods ..........................3 Data access methods: Summary ..........................5 Ordering query results ..............................7 Enabling parallel processing for queries........................7 Spreading data automatically............................8 Table scan access method ............................8 Parallel table prefetch access method ........................10 Parallel table scan method ............................11 Index scan-key selection access method .......................13 Parallel index scan-key selection access method (available only when the DB2 UDB Symmetric Multiprocessing feature is installed) ........................14 Index scan-key positioning access method ......................15 Parallel index scan-key positioning access method (available only when the DB2 UDB Symmetric Multiprocessing feature is installed) ........................19 Index Only Access Method ............................21 Parallel table or index based preload access method ..................22 Index-from-index access method ..........................22 Hashing access method .............................23 Bitmap processing method ............................24 Sort access method ..............................28 Chapter 3. The DB2 UDB for iSeries query optimizer: Overview ..............31 How the query optimizer makes your queries more efficient .................31 Optimizer decision-making rules ..........................31 Cost estimation for queries ............................32 General query optimization tips ..........................34 Access plan validation..............................34 Join optimization ................................35 Grouping optimization ..............................50 Ordering optimization ..............................54 View implementation ..............................55 Chapter 4. Optimizing query performance using query optimization tools ..........59 Verify the performance of SQL applications .......................60 Examine query optimizer debug messages in the job log ..................60 Query optimization performance information messages .................61 Query optimization performance information messages and open data paths .........66 Gather information about embedded SQL statements with the PRTSQLINF command .......67 Gather statistics about your queries with the database monitor ................69 © Copyright IBM Corp. 2000, 2001, 2002 iii Start Database Monitor (STRDBMON) command ....................70 End Database Monitor (ENDDBMON) command ....................71 Database monitor performance rows ........................72 Query optimizer index advisor ...........................72 Database monitor examples ...........................73 Gather statistics about your queries with memory-resident database monitor APIs.........78 Memory-resident database monitor external API description ................79 Memory-resident database monitor external table description ...............79 Sample SQL queries ..............................80 Memory-resident database monitor row identification ..................80 || Monitoring your database performance using SQL Performance monitors in iSeries Navigator ....80 || Creating an SQL performance monitor........................81 || Saving SQL performance monitor data (pausing a monitor) ................82 || Analyzing SQL performance monitor data ......................82 View the effectiveness of your queries with Visual Explain .................82 Change the attributes of your queries with the Change Query Attributes (CHGQRYA) command . 83 Control queries dynamically with the query options file QAQQINI ...............84 Specifying the QAQQINI file ...........................85 Creating the QAQQINI query options file .......................85 Control long-running queries with the DB2 UDB for iSeries Predictive Query Governor .......93 How the query governor works ..........................94 Cancelling a query ...............................95 Query governor implementation considerations ....................95 Query governor considerations for user applications: Setting the time limit ..........95 Controlling the default reply to the query governor inquiry message .............95 Testing performance with the query governor .....................96 Examples of setting query time limits ........................96 Control parallel processing for queries .........................97 Controlling system wide parallel processing for queries .................97 Controlling job level parallel processing for queries ...................98 || Analyzing queries with the Statistics Manager .....................100 || Statistics Manager APIs.............................100 || Managing statistical information with iSeries Navigator .................100 Query optimization tools: Comparison table ......................101 Chapter 5. Using indexes to speed access to large tables................103 Coding for effective indexes: Avoid numeric conversions..................103 Coding for effective indexes: Avoid arithmetic expressions .................104 Coding for effective indexes: Avoid character string padding ................104 Coding for effective indexes: Avoid the use of like patterns beginning with % or _ ........104 Coding for effective indexes: Be aware of the instances where DB2 UDB for iSeries does not use an index....................................105 Coding for effective indexes: Using indexes with sort sequence ...............106 Coding for effective indexes: Using indexes and sort sequence with selection, joins, or grouping 106 Coding for effective indexes: Ordering .......................106 Examples of indexes ...............................107 Index example: Equals selection with no sort sequence table ...............107 Index example: Equals selection with a unique-weight sort sequence table ..........108 Index example: Equal selection with a shared-weight sort sequence table ..........108 Index example: Greater than selection with a unique-weight sort sequence table........108 Index example: Join selection with a unique-weight sort sequence table ...........108 Index example: Join selection with a shared-weight sort sequence table ...........109 Index example: Ordering with no sort sequence table..................109 Index example: Ordering with a unique-weight sort sequence table.............109 Index example: Ordering with a shared-weight sort sequence table .............110 Index example: Ordering with ALWCPYDTA(*OPTIMIZE) and a unique-weight sort sequence table 110 iv DB2 UDB for iSeries Database Performance and Query Optimization V5R2 Index example: Grouping with no sort sequence table .................110 Index example: Grouping with a unique-weight sort sequence table ............110 Index example: Grouping with a shared-weight sort sequence table ............111 Index example: Ordering and grouping on the same columns with a unique-weight sort sequence table ...................................111 Index example: Ordering and grouping on the same columns with ALWCPYDTA(*OPTIMIZE) and a unique-weight sort sequence table ........................111 Index example: Ordering and grouping on the same columns with a shared-weight sort sequence table ...................................112 Index example: Ordering and grouping on the same columns with ALWCPYDTA(*OPTIMIZE) and a shared-weight sort sequence table ........................112 Index example: Ordering and grouping on different columns with a unique-weight sort sequence table ...................................112 Index example: Ordering and grouping on different columns with ALWCPYDTA(*OPTIMIZE) and a unique-weight sort sequence table ........................113 Index example: Ordering and grouping on different columns with ALWCPYDTA(*OPTIMIZE) and a shared-weight sort sequence table ........................113 What are encoded vector indexes? ........................113 Chapter 6. Application design tips for database performance ..............117 Database application design tips: Use live data .....................117 Database application design tips: Reduce the number of open operations ...........118 Database application design tips: Retain cursor positions .................120 Database application design tips: Retaining cursor positions for non-ILE

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    260 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us