Professional Documents
Culture Documents
An Introduction To SQL Tuning For A DB2 For ZOS Environment
An Introduction To SQL Tuning For A DB2 For ZOS Environment
Willie Favero
Data Warehouse on System z Swat Team (DB2 SME)
Session #8762
Tuesday, March 1, 2011: 3:00 PM - 4:00 PM
Note to U.S. Government Users Restricted Rights — Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services
currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used.
Any functionally equivalent product, program, or service that does not infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to
evaluate and verify the operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter described in this document. The furnishing of this document does not give you any license to these patents.
You can send license inquiries, in writing, to: IBM Director of Licensing, IBM Corporation, North Castle Drive Armonk, NY 10504-1785 U.S.A.
The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES
CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied
warranties in certain transactions, therefore, this statement may not apply to you.
This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions
of the publication. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time without notice.
Any references in this information to non-IBM Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The materials at those
Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you.
Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those
products and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be
addressed to the suppliers of those products.
This information contains examples of data and reports used in daily business operations. To illustrate them as completely as possible, the examples include the names of individuals,
companies, brands, and products. All of these names are fictitious and any similarity to the names and addresses used by an actual business enterprise is entirely coincidental.
COPYRIGHT LICENSE:
This information contains sample application programs in source language, which illustrates programming techniques on various operating platforms. You may copy, modify, and distribute
these sample programs in any form without payment to IBM, for the purposes of developing, using, marketing or distributing application programs conforming to the application
programming interface for the operating platform for which the sample programs are written. These examples have not been thoroughly tested under all conditions. IBM, therefore,
cannot guarantee or imply reliability, serviceability, or function of these programs. You may copy, modify, and distribute these sample programs in any form without payment to IBM for
the purposes of developing, using, marketing, or distributing application programs conforming to IBM's application programming interfaces.
http://www.ibm.com/legal/copytrade.shtml
EDM What?
r ry ab
It Depen D on’ t w o
od g u Buffer pools
ds! eckpoi n ts ?
ru y s
h le ai
On a ny C
o d
ei
sb ow
M WLM Policy? f t it w
ett
e
H
Many is better than one???? h u a
So
rt r tha m sa
nm OS
Sort
b
Memories Cheap an
y! !
C
a r y !
and/or ! a y V Need faster DISK
Disk is cheap
a g e M Why ca
M i l e n’t it go
faster
Y o u r My head Hurts! No S
o
S ort rt
Copyright © 2011 IBM Corporation
Tuning DB2 for z/OS Access
All rights reserved
Performance Goals and Measurements
Performance: the manner in which or the efficiency with
which something reacts or fulfills its intended purpose.
Performance Goals
should equal your
Business Goals
Performance Measurements: how we determine if we
are making our goals
Your Processes
and Your Tools
Copyright © 2011 IBM Corporation
Tuning DB2 for z/OS Access Slide 6 of 59
All rights reserved
What Is Tuning?
Reducing Wait Times Due to:
• I/O contention, Locks, Logs, etc...
GETPAGE
–How DB2 satisfies your request for data from a page
I/O
–What DB2 uses if page needed is NOT in the buffer pool
“You
“Youcan’t
can’tstart
startaajourney
journeywithout
withoutaadestination”
destination”
OLTP?
Batch?
Distributed?
Data Warehouse?
Monitor
Do
Tune Forever
Repeat
SQL
Processor
Disk
Local Work
Database System
BTW, this is my opinion…
Copyright © 2011 IBM Corporation
Tuning DB2 for z/OS Access Slide 15 of 59
All rights reserved
Access Path Selection
Statistics from Valid SQL DB2 Internal Cost
DB2 Catalog Formulas
DB2
Next Slide
Optimizer
Cost based
I/O Cost
z
SQL optimization
CPU Cost z
TS Scan vs. Index Scan Traversing Rows and
Index Scan Pages
(MATCHCOLS, Applying
CLUSTERRATION) Predicates(RDS vs.
Workfile Scans DM)
DSNDB07 Cost of sorting
Etc…. Etc…
RUNSTATS
–More statistics are not always better
–Running RUNSTATS does have a cost
–Consider Statistics Advisor
• Optimizer Service Center (deprecated in DB2 9)
• Data Studio (stand alone version only)
• Optim Query Tuner
• Optim Query Workload Tuner
>= 2 1/3 1 / 10
=1 1 1
>= 0 1/3 1 / 10
or
–DSNZPARM
• DSN6SPRM macro and CACHEDYN keyword
Performance Expectation
–Using parameter marker still provides best performance
–Biggest performance gain for small SQL with literals that can now have
a cache
–NOTE: Access path is not optimized to provided literals
• True for parameter markers/host variables today
• Need to use REOPT for that purpose
IFCID 317
–Used in addition to IFCID 316 to obtain the full SQL statement text
• http://publib.boulder.ibm.com/infocenter/tivihelp/v15r1/index.jsp?topic=/com.ibm.ome
gamon.xe_db2.doc/ko2rrd20228.htm
IFCID 318
–Acts as a switch for IFCID 316 to collect all available information
• Stop and Start for new interval
NOT FIFO
REOPT(ONCE)
–DB2 reoptimizes cached dynamic SQL statements at execution time
for the first execution of the statement based on literal values that are
provided for parameter markers
a r accelerator
Russian
Gracias Spanish
Merci
French
Obrigado
Brazilian Portuguese
Arabic
Bedankt Danke
German
Nederlands
Simplified Chinese
Japanese
wfavero@attglobal.net