DB2 Performance Tuning Using Omegamon DB2 Performance Expert Akiko - HOSHIKAWA
DB2 Performance Tuning Using Omegamon DB2 Performance Expert Akiko - HOSHIKAWA
DB2 Performance Tuning Using Omegamon DB2 Performance Expert Akiko - HOSHIKAWA
• Objectives:
• Provides the first step of understanding the most important DB2
traces - accounting and statistics
• Using batch report from IBM Tivoli OMEGAMON XE for DB2
Performance Expert on z/OS (OMPE), examine real case
studies
• Agenda
• Part I : DB2 trace basics
• Statistics and Accounting traces
• From workload to thread level
• Part II : Case studies
• Examples : How to use DB2 traces to tune the DB2 applications
DB2 Application Monitoring and Tuning -
Start with Drill Down CICS transactions
Utility A
TSO B Package D
C CPU
DDF CICS
I/O WAIT
D
Others
• CLASS 1,2,3,4,5,6,7,8,10
• Recommend Class(1,2,3,7,8)
Statistics Trace & Report
• Statistics trace is a prime indicator of system status and
performance
• Address space CPU time • Pools/Storage usage
• TCB and SRB time for • EDM pools
• MSTR, DBM1, IRLM, DDF • RID pool
• Statement cache
• zIIP time under address
• Local Buffer pools
space
• Group buffer pools
• Workload at system level • Workfile usage
• DML/DDL activities • Authorization cache
• Locking activities • Virtual and real storage usage
• DB2 latches • zOS metrics
• Log activities
• Plan/Package
• DRDA activities
• Open/Close
Statistics Monitoring - Best Practices
13
Notes : DB2 Accounting data is written at
• Thread deallocation (including abends)
• (re)signon in case of thread reuse by IMS/CICS
• ACCOUNTREC (UOW / TASK) in DB2ENTRY for CICS
• At commit for RRS threads using accounting-interval COMMIT on signon/ auth
signon / context signon
• At commit when CMTSTAT=INACTIVE and provided connection can go inactive
• JCC applications : same packages (i.e SYSLN200)
• to identify a specific JDBC transaction/application, accounting strings need to be set.
• setDB2ClientAccountingInformation
• db2.jcc.accountingInterval=COMMIT in DB2JccConfiguration.properties
• Things that prevent a connection from going inactive:
• Touched a package that uses Keepdynamic(yes)
• If only reason for not going inactive is the use of keepdynamic(yes), still cut acctg (and reset enclave)
• Active DGTT (not explicitly or implicitly dropped)
• Open cursor with hold
• Held LOB locator
14
Notes: How To Set Client Information
• Ease of analysis
• PLANNAME: db2jcc_a if you do not set client info set
• Java methods for existing Set Client Information API
• setClientUser(zheng)
• setClientWorkStation(CL01)
• setClientApplicationInformation(payment)
• setClientAccountingInformation(String)
• WebSphere Application Server before V6.0
• Only settable as DB2 DataSource property
• limited because information can not be changed dynamically
• WebSphere Application Server Version 6.0 supports explicite and implicite setting
of client information
• Example how to call explicitely
• WSConnection conn = (WSConnection) ds.getConnection();
• props.setProperty(WSConnection.CLIENT_ID, "user123");
• conn.setClientInformation(props);
• Example how to call implicitely by turning on WebSphere Trace Group
• WAS.clientinfo=all=enabled or
• WAS.clientinfopluslogging=all=enabled
DB2 Traces and Overhead
• DB2 Statistics : Negligible
• DB2 Accounting : CPU Typically less than 5%
• Class 1: less than 5% CPU overhead
• Class 2: 1 to 10% CPU overhead, typically less than 5%
• Class 2 accounting (SQL statement level)
• Can be higher for fetch-intensive applications, up to 20%
• V8 multi-row Fetch can make this overhead negligible
• Class 3: less than 1% CPU overhead
• Much higher than 1% cpu overhead for class 3 acctg has been observed in
a rare situation of very high internal DB2 latch contention rate, eg over
10000/sec.
• Class 7 and 8 (Package): less than 1-3% cpu overhead,
• Class 10 (Package Detail) : 2-5% overhead
CPU time and Trace / Monitor Products
CPU TIMES TCB TIME PREEMPT SRB NONPREEMPT SRB TOTAL TIME PREEMPT IIP SRB /COMMIT
------------ ------------ --------------- ------------- -------------- --------------- ------
SYSTEM SERVICES ADDRESS SPACE 0.311114 5.912448 0.020002 6.243564 N/A 0.000019
DATABASE SERVICES ADDRESS SPACE 6.097576 48.396869 0.697035 55.191480 0.000000 0.000166
IRLM 0.000108 0.000000 0.296435 0.296543 N/A 0.000001
DDF ADDRESS SPACE 0.056293 4:15.988350 11.350365 4:27.395008 0.000000 0.000803
TOTAL 6.465091 5:10.297667 12.363837 5:29.126594 0.000000 0.000988
CONNTYPE CL1 ELAPSED CL1 CPU CL1 SE CPU CL2 ELAPSED CL2 CPU CL2 SE CPU CL3 SUSP THREADS
-------- ------------- ----------- ------------ ------------ --------- ------- ---------- --------
BATCH 1:14.326062 8.882753 0.000000 1:14.234073 8.879979 0.000000 1:05.997069 3.00
CICS N/P N/P N/P N/P N/P N/P N/P 0.00
DDF 1:23:47.54247 4:02.519462 0.000000 1:11:52.05797 2:33.206501 0.000000 1:07:58.67980 221.0K
IMS N/P N/P N/P N/P N/P N/P N/P 0.00
RRSAF 1:40:13.74934 1:46.557250 0.000000 1:11:53.96995 1:09.962190 0.000000 1:10:43.87768 110.1K
UTILITY 27:27.200715 9:09.367476 0.000000 9:54.465831 6:40.422900 0.000000 1:30.511908 16.00
Find Focus Area – Top Consumers
ata Studio V3.1 incorporates this procedure into a GUI (Best Practice)
– http://www.ibm.com/developerworks/downloads/im/data/
• No charge product, replacement for OSC and Visual Explain
• Several versions:
– DBA’s should download the Administration Client
• Incorporates Statistics Advisor
• FTP doc directly to DB2 Level 2
• Can be used to duplicate stats in TEST environment
• PART I
• Most Important DB2 Traces - Accounting and Statistics
• OMPE support on Aggregated Accounting in Statistics
• Creating Effective Accounting Reports
• Case Study (1) – DB2 CPU Increase at Migration
• PART II
• Case Study (2) – Sync I/O Wait
• Case Study (3) – DB2 CPU Increase
• Case Study (4) – Page Latch Contention
• Case Study (5) – Page Latch Contention
• Case Study (6) – Monitoring accelerated queries using IDAA
Accounting Class 1,2,3 and 7,8
Class 1 Class 2 Class 3
elapsed elapsed Suspensions
and CPU and CPU
thread allocation
1st SQL
2nd SQL
Class 7 and 8 is
used for package
thread deallocation scope reporting.
It is equivalent to
Class 2 and 3.
In DB2
In DB2
Out of DB2 Out of DB2
CPU
CPU
Wait time Wait time
Case Study (2) Sync I/O Wait -1
MARKET#0 AVERAGE TIME AVG.EV
------------------ ------------ ------
LOCK/LATCH 0.001157 2.05
Avg 1.4 ms
SYNCHRONOUS I/O 0.117791 81.96
per I/O req
OTHER READ I/O 0.002557 1.26
OTHER WRITE I/O 0.000000 0.00
TOTAL CL8 SUSPENS. 0.121505 85.26
MARKET#0 AVERAGE TOTAL
------------------ ------------ ------------
BPOOL HIT RATIO (%) 13.55 N/A
GETPAGES 605.21 2126103
BUFFER UPDATES 0.01 51
SYNCHRONOUS WRITE 0.00 0
SYNCHRONOUS READ 81.96 287925
Synchronous Database I/O Suspensions
application DB2
address space address space • A common timer for:
− Synchronous database reads
− Synchronous database writes
SELECT − Delay due CPU constraint
getpage miss
read begin • A separate timer for
w synchronous log writes
a
• Use BP statistics to find out how
i
many of the suspensions should
t
read end be attributed to synchronous
reads vs. writes
buffer update
• Avg I/O wait time in Acctg rpt =
0.028539 ms/12.41 events =
0.002 msec / sync DB IO
When You See High I/O Wait ..
• Verify if access path is optimal
• Excessive Getpage
• Identify which objects
from BPOOL section
• Verify average I/O resp time
• If significantly larger than RMF
• CPU delay instead of I/O delay
• Buffer Pool Tuning
• REORG : Data/Index
• I/O configuration tuning using RMF data
• DISK CACHE hit
• DASD Acitivity report
• Make sure of sufficient I/O resources
• Hiper PAV (Parallel Access Volume) for concurrent I/O
• SSD hot data which cannot be fit in DB2 buffer pools
Notes: Buffer Pool Guideline
• Buffer pool hit ratio = GETPAGE req/ Sync Read
• Buffer pool separation
• For example,
• Index, Data, Workfile
• Write intensive data and read intensive data
• In memory buffer pool
• Page steal - FIFO
• Disable prefetch - avoid unnecessary prefetch
• High VDWQT threshold - keep pages in buffer pools
• Compressed data page stays compressed in buffer pool, expands when rows are
evaluated
• Compressed index (V9 NFM) is expanded in buffer pool
• Control unit caching
• Control unit cache is typically larger than buffer pools (= real storage)
• Compression can raise control unit cache if not buffer pool hit
• Workfile bpool
• Set Sequential Prefetch threshold = 99 % as all workfile read are sequential
• Assign enough 32K workfile buffers for DB2 9.
• Before DB2 9 record size > 4K uses 32K workfile
• DB2 9 record ize > 100bytes uses 32K workfile
Notes : Buffer Pool Guideline – Index buffer
pools
• Generally, assign more buffers than data
• Better chance to be utilized than Table
• For large indexes, at least assign enough buffers for non-leaf
pages
• 1billion rows table with 200 index entries per 4K pages
• 1,000 M / 200 = 5,000,000 Leaf Pages
• 5,000,000 / 200 = 25,000 Level 2 (Non Leaf)
• 25,000 / 200 = 125 Level 3 (Non Leaf)
• 125 / 200 = 1 Level 4 (Non leaf)
• Total Non Leaf page = 25126
• Consider to use Large Index pages (V9 NFM) if the index is accessed key
order
• Getpage and split reduction
• Compressed Index page is expanded at I/O time, stays uncompressed
in buffer pool.
Case Study (2) Sync I/O Wait -2
MARKET#0 AVERAGE TIME AVG.EV
------------------ ------------ ------ Sync I/O reduction by
LOCK/LATCH 0.001157 2.05 1. Separate BPOOL
SYNCHRONOUS I/O 0.117791 81.96 for better hit ratio
OTHER READ I/O 0.002557 1.26
2. Increase BPOOL
OTHER WRITE I/O 0.000000 0.00
TOTAL CL8 SUSPENS. 0.121505 85.26
size
3. Compress the
data page
MARKET#0 AVERAGE TIME AVG.EV
------------------ ------------ ------
LOCK/LATCH 0.000569 1.57
SYNCHRONOUS I/O 0.000495 0.62
OTHER READ I/O 0.000000 0.00
OTHER WRITE I/O 0.000000 0.00
TOTAL CL8 SUSPENS. 0.001064 2.19
Case Study (3) DB2 CPU Increase -1
BEFORE
TIMES/EVENTS APPL(CL.1) DB2 (CL.2) CLASS 3 SUSPENSIONS ELAPSED TIME EVENTS HIGHLIGHTS
------------ ---------- ---------- -------------------- ------------ -------- --------------------------
ELAPSED TIME 5:42.43304 5:41.25154 LOCK/LATCH(DB2+IRLM) 0.011943 899 THREAD TYPE : ALLIED
NONNESTED 5:42.43304 5:41.25154 IRLM LOCK+LATCH N/A N/A TERM.CONDITION: NORMAL
STORED PROC 0.000000 0.000000 DB2 LATCH N/A N/A INVOKE REASON : DEALLOC
UDF 0.000000 0.000000 SYNCHRON. I/O 1:29.529632 140511 PARALLELISM : NO
TRIGGER 0.000000 0.000000 DATABASE I/O 1:29.529632 140511 PCA RUP COUNT : N/A
LOG WRITE I/O 0.000000 0 RUP AUTONOM.TX: N/A
CP CPU TIME 2:49.02071 2:48.90302 OTHER READ I/O 1:17.309059 19145 AUTONOMOUS TX : N/A
AGENT 2:49.02071 2:48.90302 OTHER WRTE I/O 0.528574 964 QUANTITY : 0
NONNESTED 2:49.02071 2:48.90302 SER.TASK SWTCH 0.005164 2 COMMITS : 1
STORED PRC 0.000000 0.000000 UPDATE COMMIT 0.000760 1 ROLLBACK : 0
AFTER
TIMES/EVENTS APPL(CL.1) DB2 (CL.2) CLASS 3 SUSPENSIONS ELAPSED TIME EVENTS HIGHLIGHTS
------------ ---------- ---------- -------------------- ------------ -------- --------------------------
ELAPSED TIME 1:30:35.31 1:30:33.65 LOCK/LATCH(DB2+IRLM) 0.005413 865 THREAD TYPE : ALLIED
NONNESTED 1:30:35.31 1:30:33.65 IRLM LOCK+LATCH 0.002994 8 TERM.CONDITION: NORMAL
STORED PROC 0.000000 0.000000 DB2 LATCH 0.002419 857 INVOKE REASON : DEALLOC
UDF 0.000000 0.000000 SYNCHRON. I/O 1:21.613858 149888 PARALLELISM : NO
TRIGGER 0.000000 0.000000 DATABASE I/O 1:21.613858 149888 PCA RUP COUNT : N/A
LOG WRITE I/O 0.000000 0 RUP AUTONOM.TX: N/A
CP CPU TIME 1:26:14.02 1:26:13.91 OTHER READ I/O 1:07.245210 14135 AUTONOMOUS TX : N/A
AGENT 1:26:14.02 1:26:13.91 OTHER WRTE I/O 0.421171 621 QUANTITY : 0
NONNESTED 1:26:14.02 1:26:13.91 SER.TASK SWTCH 2.682449 163 COMMITS : 1
STORED PRC 0.000000 0.000000 UPDATE COMMIT 0.000833 1 ROLLBACK : 0
DB2 CPU time
Before : 2:48.90
After : 1:26:13.91
Case Study(2) – DB2 CPU Increase -2
Key Counters In Accounting
Good case (V9) Bad case (V10)
CL2 Elapsed Time 5:41.251 1:30:33.650
CL2 CPU Time 2:48.903 1:26:13.912
CL3 Suspension Time 2:37.384 2:31.968
Commit 1 1
SELECT 2 2
UPDATE / ROWs 1/1 1/1
OPEN / CLOSE 3/3 3/3
FETCH / ROWS 74 / 71 74 / 71
GETPAGES 6143825 6135464
Sync Read 140518 149888
Dyn. Prefetch 104050 440213
Pages Read Async 1607301 1610632
Case Study(2) CPU Increase -3
Space Map pages • Larger page size (32K) should reduce frequency of
space map update
Case Study(5) Concurrent Insert Transaction -3
The workshops, sessions and materials have been prepared by IBM or the session speakers and reflect their own views. They are
provided for informational purposes only, and are neither intended to, nor shall have the effect of being, legal or other guidance or advice
to any participant. While efforts were made to verify the completeness and accuracy of the information contained in this presentation, it
is provided AS-IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use
of, or otherwise related to, this presentation or any other materials. Nothing contained in this presentation is intended to, nor shall have
the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the
applicable license agreement governing the use of IBM software.
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. Nothing contained in these
materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific
sales, revenue growth or other results.
IBM, the IBM logo, ibm.com, DB2, CICS and IMS are trademarks or registered trademarks of International Business Machines
Corporation in the United States, other countries, or both. If these and other IBM trademarked terms are marked on their first occurrence
in this information with a trademark symbol (® or ™), these symbols indicate U.S. registered or common law trademarks owned by IBM
at the time this information was published. Such trademarks may also be registered or common law trademarks in other countries. A
current list of IBM trademarks is available on the Web at “Copyright and trademark information” at www.ibm.com/legal/copytrade.shtml
Other company, product, or service names may be trademarks or service marks of others.