Escolar Documentos
Profissional Documentos
Cultura Documentos
Marcel Lvy
Natixis
Guide DB2A
Le jeudi 5 dcembre 2013
Agenda
Disclaimer: Information provided without any warranty or liability and use of this
information is at the sole risk of the user. The author and his company are not
responsible or liable for the availability of these resources and for any content.
Limitations
Dont always expect to improve this way
Fix the consequences and never the original causes
Application change usually gives better results
Development thinks the problem is fixed for good
Bypass might not work anymore after a change:
DB2 level, DB2 configuration, program, data, access pattern
People might consider youre responsible if not working anymore
DB2 as a camera
Automatic mode: DB2 defaults and no new features.
Minimal knowledge required. Are you afraid of changes?
Manual mode: choose adapted values for DB2 options and new
features if you know what you are doing. Results should be better
or worse if you dont understand business rules.
Professional photographers use manual mode for better pictures.
#SQL calls
#getpages
#locks
#pages read
#rows processed
#rows sorted
Look for big numbers and make sure these numbers are
appropriate. Compare with similar efficient processes.
Reduce large values in order to decrease CPU time.
Following example will show you some opportunities.
ELAP_DB2
1458
1283
1381
1319
1415
1446
1380
SQL/CPU
637
640
626
596
576
589
582
NB_SQL
574477
534510
533468
494400
542112
527485
515600
10
IN DB2
274 ms
198 ms
12 ms
64 ms
IN APPL.
20 ms
4,574 us
TOTAL
294 ms
202 ms
TOTAL SQL.....................205
GETPAGES....................7,169
SYNC READS (PRLL=00)...........15
PREFETCH PAGES READ...........150
PACKAGE
P093DTE
P102DTE
P732DTE
NO. SQL
4
116
85
CPU TIME
534 us
194 ms
2,750 us
GETPAGES FROM BP1 (index) : 6,959 with 235 dynamic prefetch events
11
COUNT
----1
1
1
1
2
1
1
1
AVG.
%
ELAPSED ELAP
-------- ----13 us
0.0
469 us
0.2
6 us
0.0
192 us
0.1
89 ms 60.7
1,471 us
0.6
85 ms 32.1
76 us
0.0
AVG.
%
CPU
CPU
-------- ----12 us
0.0
95 us
0.0
6 us
0.0
170 us
0.1
62 ms 63.5
183 us
0.1
63 ms 32.7
41 us
0.0
SORT
RECS
---0
0
0
0
0
0
60
0
PAGES SCANNED
INDX DATA WORK+
---- ---- ---6
4
0
2
1
0
0
0
0
4
1
0
4550
83
0
2
1
0
2277
41
0
0
0
0
12
COUNT
----2
COUNT(*)
TBAD043
COL1 = :H
COL2 = :H
COL5 = :H
COL6 = :H
COL9 = :H
AVG.
%
ELAPSED ELAP
-------- ----89 ms 60.7
AVG.
%
CPU
CPU
-------- ----62 ms 63.5
SORT
RECS
---0
PAGES SCANNED
INDX DATA WORK+
---- ---- ---4550
83
0
COUNT(*)
TBAD043
Performance trace shows value of host-variables
COL1 = 20
COL2 = RETB
COL5 = A
COL6 = '2013-06-18-00:00:00.000000
COL9 = 1
Results: 60
SELECT
FROM
WHERE
AND
COUNT(*)
TBAD043
COL1 = 20
COL2 = 'RETB
Results: 270257
SELECT COUNT(*)
FROM TBAD043
WHERE COL1 = 20
AND COL2 = 'RETB
AND COL6 = '2013-06-18-00:00:00.000000
Results: 60
Create new index?: IXAD043C (COL1, COL2, COL6 desc) non unique
Modify existing index?: IXAD043B (COL1, COL2, COL6 desc, COL3) non unique
Opportunity for index only?: if really necessary.
13
14
COUNT
----1
AVG.
%
ELAPSED ELAP
-------- ----85 ms 32.1
AVG.
%
CPU
CPU
-------- ----63 ms 32.7
SORT
RECS
---60
PAGES SCANNED
INDX DATA WORK+
---- ---- ---2277
41
0
Create new index?: IXAD043C (COL1, COL2, COL6 desc, COL17 desc, COL18 desc)
Modifiy existing index?:
IXAD043B (COL1, COL2, COL6 desc, COL17 desc, COL18 desc, COL3)
because no matching 3 columns IXAD043B access path found in PLAN_TABLE.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#EXEC
1
1
1
1
1
CPU_DB2
72
67
50
64
61
ELAP_DB2
571
520
382
484
519
SQL/CPU
517
483
439
465
413
NB_SQL
37279
32657
22081
29859
25019
29
IN DB2
00:10:06
00:01:55
00:07:26
45 s
IN APPL.
00:02:16
41 s
TOTAL
00:12:22
00:02:36
TOTAL SQL..................6,082K
GETPAGES...................4,430K
SYNC READS (PRLL=00).......74,337
PREFETCH PAGES READ........4,429K
PACKAGE
P500NST
P634NST
P035NST
SQL metric:
410
SQL metric: 111,870
30
STMT
TYPE
OPEN
FETCH
CLOSE
SECT
NO.
1
1
1
GETPAGES
2601
11
0
SIOS
TOTAL
113
0
0
P500NST
P500NST
P500NST
OPEN
FETCH
CLOSE
2
2
2
1490
667 00:00.00619
1503 11842 07:47.19945
1544
667 00:00.00393
0 00:00.00576
90 00:59.52724
0 00:00.00330
0
99
0
0
3540K
0
0
64145
0
P500NST
SELECT
10 00:00.51287
19972
9161
DECLARE
SELECT
FROM
WHERE
AND
AND
AND
AND
AND
C2 CURSOR FOR
Matching 1 column index IXDF090D with sequential prefetch
COL1, / , COL34
TBDF090
COL1 = :H matching
COL4 = :H
COL5 = :H screening
NUMBER
WAIT TIME
COL6 = :H
SYNC I/O......: 64145
00:02:21
COL7 = :H
ASYNC READ I/O: 90490
00:04:12
COL8 = :H
31
32
COL1
5500
1177
5500
COL5
8923
8154
8221
COUNT
270222
173814
170980
.../...
COL1
5500
5500
5500
COL5
8923
8923
8923
COL4
RIL
RIL
RIL
COL6
EFG
EFG
SF9
COL7
14.02.2002
17.04.2001
02.09.1998
COL8
14.02.2002
17.04.2001
02.09.1998
COUNT
99640
82740
496
5500
8923
RIL
PWD
17.07.1999
17.07.1999
.../...
Create new index?: IXDF090G (COL1, COL5, COL6, COL7) non unique
33
34
Bad behavior
OLTP: a lot of sync. I/Os and async. I/Os
Batch: a lot of sync. I/Os and a few async. I/Os
(as known as Death by Random I/Os)
35
36
37
38
Go further 1
Theres a common misunderstanding about DB2
performance issue:
DB2 Application performance
DB2 DBMS performance
39
Go further 2
With VARCHAR type, test and use
Non-padded index
RRF (Reordered Row Format)
CHAR if max column length is less than 18
Enough freespace for column update
40
Go further 3
How to solve a DB2 Performance Problem?
41
Go further 4
Estimate gains and cost to implement
in order to compute Return On Invest for your Manager.
Update your company standards with DB2 features
available in 2013 (Version 10, not Version 3).
Dont be afraid to use new features: evaluate, test, write
best practices and update your company standards.
During your review, dont forget to note any potential
change that imply SQL or program change.
IBM improved SQL runtime with disorganized index.
Time to experiment less REORGs in order to save CPU
cycles and decrease locking issues with bad applications?
42