IBM eServer iSeries 8 CopyrightIBM Corporation, 2005. A llRightsReserved. Thispublication m ay referto productsthatare notcurrently available in yourcountry. IBM m akesno com m itm entto m ake available any productsreferred to herein. Session: Intro to Query Optimization DB2 UDB for iSeries Tom McKinley IBM Rochester, MN USA
33
Embed
Introduction to the Query Optimizer and Database Engine for DB2 ...
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
IBM eServer iSeries
8 Copyright IBM Corporation, 2005. All Rights Reserved.
This publication may refer to products that are not currently available in your country. IBM makes no commitment to make available any products referred to herein.
–>1 Table (i.e. no joins)–OR & IN predicates–SMP requested–Non-Read (INSERT with subselect can use new path)–LIKE predicates–UNIONS–View or Logical File references–Subquery–Derived Tables & Common Table expressions, UDTFs–LOB columns–LOWER, TRANSLATE, or UPPER scalar function–CHARACTER_LENGTH, POSITION, or SUBSTRING scalar function using UTF-8/16–Sort Sequences & CCSID translation between columns–Distributed queries via DB2 Multisystem–Non-SQL queries (QQQQry API, Query/400, OPNQRYF)–ALWCPYDTA(*NO) specified–Sensitive Cursor
SQE support added into V5R2 - May 2003(Latest DB Group + SI07650)
Back up to CQE to complete optimization if any of the following are encountered:
–Select/omit logical file–Logical file over multiple members–Join logical file–Derived key (s)
ƒ Native logical files that perform some intermediate mapping of the fields referenced in the key. Common ones are renaming fields, adding a translate or only selecting a subset of the columns
ƒ Specifying an Alternate Collating Sequence (ACS) on a field used for a key will also make a “derived key” (an implied map occurs within the index)
–Sort Sequence (NLSS) specified for index or logical fileƒ Probably the trickiest one to detect for users. The index is built while an NLSS table is specified in the query environment
–Cost to “back up” and revert to CQE adds about 15% to the total optimization time
–QAQQINI parameter to ignore unsupported logical filesƒ Ignore_Derived_Index = *YES
Query Dispatcher–Determine which query engine should complete the processing
Query Optimization–Choose most efficient access method–Builds access plan
Query Execution–Build the structures needed for query cursor–Build the structures for any temporary indexes (if needed)–Builds and activates query cursor (ODP)–Generate any feedback requested
Debug messages in the job logDB Monitor recordsVisual Explain
Query optimization will generally follow this simplified strategy:
Gather meta-data and statistics for costingSelectivity statisticsIndexes available to be costed
Sort the indexes based upon their usefulness
Environmental attributes that may affect the costsGenerate default cost
Build an access plan associated with the default planFor each index:
Gather information needed specific to this indexBuild an access plan based on this indexCost the use of the index with this access planCompare the resulting cost against the cost from the current best plan
ƒ More accurately describes multi-column key valuesƒ Stats available immediately as the index maintenance occursƒ Selectivity estimates from radix by reading n keysƒ Selectivity from EVI by reading symbol table values
–Column Statistics
ƒ SQE onlyƒ Column Cardinality, Histograms & Frequent Values Listƒ Constructed over a single column in a tableƒ Stored internally as a part of the table object after createdƒ Collected automatically by default for the systemƒ Stats not immediately maintained as the table changesƒ Stats are refreshed as they become “stale” over time
IBM Corporation 1994-2005. All rights reserved.References in this document to IBM products or services do not imply that IBM intends to make them available in every country.
The following terms are trademarks of International Business Machines Corporation in the United States, other countries, or both:
Rational is a trademark of International Business Machines Corporation and Rational Software Corporation in the United States, other countries, or both.Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.Microsoft, Windows, Windows NT, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both. Intel, Intel Inside (logos), MMX and Pentium are trademarks of Intel Corporation in the United States, other countries, or both.UNIX is a registered trademark of The Open Group in the United States and other countries.SET and the SET Logo are trademarks owned by SET Secure Electronic Transaction LLC. Other company, product or service names may be trademarks or service marks of others.
Information is provided "AS IS" without warranty of any kind.
All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics may vary by customer.
Information concerning non-IBM products was obtained from a supplier of these products, published announcement material, or other publicly available sources and does not constitute an endorsement of such products by IBM. Sources for non-IBM list prices and performance numbers are taken from publicly available information, including vendor announcements and vendor worldwide homepages. IBM has not tested these products and cannot confirm the accuracy of performance, capability, or any other claims related to non-IBM products. Questions on the capability of non-IBM products should be addressed to the supplier of those products.
All statements regarding IBM future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only. Contact your local IBM office or IBM authorized reseller for the full text of the specific Statement of Direction.
Some information addresses anticipated future capabilities. Such information is not intended as a definitive statement of a commitment to specific levels of performance, function or delivery schedules with respect to any future products. Such commitments are only made in IBM product announcements. The information is presented here to communicate IBM's current investment and development activities as a good faith effort to help with our customers' future planning.
Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput or performance that any user will experience will vary depending upon considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve throughput or performance improvements equivalent to the ratios stated here.
Photographs shown are of engineering prototypes. Changes may be incorporated in production models.