Advanced Internal Oracle Tuning Techniques For SAP Systems: Michael Kennedy SMS Consulting
Advanced Internal Oracle Tuning Techniques For SAP Systems: Michael Kennedy SMS Consulting
_________________________________
_________________________________
_________________________________
Advanced Internal
Oracle Tuning
Techniques for
SAP Systems
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
Michael Kennedy
SMS Consulting
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
1
B*Tree Design
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
2
B*Tree Indexes
_________________________________
_________________________________
All leaf blocks, which hold the row ID, are on the same level
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
3
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
4
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
5
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
6
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
7
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
8
Inefficient SQL
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
9
Efficient SQL
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
10
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
11
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
12
_________________________________
Tracing the CBO (event 10053) can help prove why the
CBO is not picking the correct index
Parameters that affect the CBO:
_________________________________
_________________________________
db_file_multiblock_read_count = 8
f The higher the value, the lower the cost of a full tablescan
optimizer_index_cost_adj = 10
f The lower the value, the lower the cost of an index access
Event 10183
f Used in conjunction with optimizer_index_cost_adj when two
indexes have a cost calculation less than one
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
13
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
14
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
15
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
16
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
17
Rebuilding Indexes
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
18
_________________________________
_________________________________
_________________________________
Program RSORATAD
Ran for one hour on 20 GB index MSEG~0 with 304 million rows
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
19
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
NAME
HEIGHT
LF_ROWS DEL_LF_ROWS
PCT_USED
-------------------- ---------- ---------- ----------- ---------TST03~0
3
159608
115497
54
_________________________________
_________________________________
20
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
USERNAME TABLESPACE
SID CONTENTS SEGTYPE
EXTENTS
Bytes
---------------------- ---------- --------- --------- ---------- ---------------SAPRTL
PSAPTEMP
393 TEMPORARY SORT
64
67,108,864
SAPRTL
PSAPTEMP
384 TEMPORARY SORT
40
41,943,040
SAPRTL
PSAPTEMP
367 TEMPORARY SORT
80
83,886,080
SAPRTL
PSAPTEMP
395 TEMPORARY SORT
61
63,963,136
SAPRTL
PSAPTEMP
382 TEMPORARY SORT
67
70,254,592
---------- ---------------sum
312
327,155,712
_________________________________
_________________________________
21
_________________________________
With this script, you can monitor the index being created
in the target tablespace
_________________________________
_________________________________
SEGMENT_NAME
--------------31.680100
63.290980
97.325500
208.153460
237.178036
sum
_________________________________
_________________________________
_________________________________
TABLESPACE_NAME
BYTES
EXTENTS
--------------- ---------------- ---------PSAPRTL
98,631,680
84
PSAPRTL
79,626,240
81
PSAPRTL
85,262,336
82
PSAPRTL
81,002,496
81
PSAPRTL
95,420,416
86
---------------- ---------439,943,168
414
_________________________________
_________________________________
_________________________________
_________________________________
22
_________________________________
_________________________________
Run the create or rebuild index during a low peak time, because high Data
Manipulation Language (DML) may cause a table lock (SAP Note 682926)
_________________________________
_________________________________
_________________________________
_________________________________
The index will need to be dropped and recreated if using Oracle dataguard
The index will need to be dropped and recreated if a recovery is needed if a
backup was not taken after the create or rebuild command
_________________________________
_________________________________
_________________________________
_________________________________
23
_________________________________
Program RSANAORA
List of Indexes in variant
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
24
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
25
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
26
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
27
BSAS Solution
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
28
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
29
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
V$SESSION_WAIT
V$SYSTEM_EVENT
V$SESSION
V$LOCK
SAP Transaction ST04 Detailed Analysis Oracle Sessions
_________________________________
_________________________________
_________________________________
_________________________________
30
_________________________________
Session is waiting for I/O when doing a FULL TABLESCAN or FAST FULL
INDEX scan. Multi-block operations are done.
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
Session is waiting for I/O from an explain plan using an index. A single
block I/O is done.
_________________________________
The session is waiting for the LGWR to write the data from the log buffer to
the online redo logs because of the commit.
_________________________________
_________________________________
LATCH FREE
The session is waiting for an Oracle Latch. Use P2 value to determine latch
name to resolve the issue in 9i. Oracle 10G will show the full latch name.
_________________________________
31
ENQUEUE
_________________________________
_________________________________
_________________________________
_________________________________
The session is waiting for the DBWR to clean up dirty blocks in the Oracle
buffer cache
_________________________________
_________________________________
_________________________________
The session is waiting for the DBWR to write the dirty block to disk
The session is waiting for an Oracle Enqueue, which is most likely either a(n):
f ST Enqueue Space Transaction Enqueue for extent management
f TX Enqueue Multiple sessions modifying the exact same row
concurrently (usually a SELECT FOR UPDATE)
_________________________________
_________________________________
Waiting for exclusive lock to the library cache and may indicate a Shared
Pool issue
_________________________________
32
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
33
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
34
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
SID
SEQ# EVENT
P1
P2
P3 SECONDS_IN_WAIT
---------- ---------- ------------------------------ ---------- ---------- ---------- --------------624
18902 buffer busy waits
354
44041
130
0
2002
41785 db file scattered read
286
73460
8
0
157
30307 db file sequential read
53
320723
1
0
2245
1775 db file sequential read
354
44209
1
0
11
48565 log file parallel write
2
20
2
0
_________________________________
_________________________________
35
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
36
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
37
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
38
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
39
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
SID Lock
Mode
----- ------ ---------------------------------------383 TX
4
385 TX
4
_________________________________
40
_________________________________
For 9i, use the following script to see the object and row of the
enqueue prompt. This will show the object and row of enqueue.
In this example, the Object 122961 is where the TX enqueue occurs.
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
SID EVENT
ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW# SECONDS_IN_WAIT
---------- --------- ------------- -------------- --------------- ------------- --------------381 enqueue
122961
25
25020
0
46
383 enqueue
122961
25
25020
0
43
385 enqueue
122961
25
25020
0
80
_________________________________
_________________________________
_________________________________
41
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
42
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
43
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
44
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
45
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
46
_________________________________
SQL> alter session set events '10046 trace name context forever,
level 12';
_________________________________
Session altered.
_________________________________
_________________________________
_________________________________
COUNT(*)
---------386544
_________________________________
SQL> alter session set events '10046 trace name context off';
_________________________________
Session altered.
_________________________________
_________________________________
_________________________________
47
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
48
_________________________________
Wait information:
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
49
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
50
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
51
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
PID
---------22
_________________________________
52
_________________________________
Now that we have the Oracle PID, we can use another Oracle
tracing method, ORADEBUG, to attach and trace what is
happening with the process.
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
53
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
Waited 30 seconds......
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
54
_________________________________
Below is the output from the 10046 trace of the SAP work process
23732, which was running a SELECT on table ECMCA.
Notice the elapse (ela) times to fetch the block from disk into the
buffer cache are very fast!
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
#332:
#332:
#332:
#332:
#332:
#332:
#332:
#332:
#332:
#332:
#332:
#332:
nam='db
nam='db
nam='db
nam='db
nam='db
nam='db
nam='db
nam='db
nam='db
nam='db
nam='db
nam='db
file
file
file
file
file
file
file
file
file
file
file
file
sequential
sequential
sequential
sequential
sequential
sequential
sequential
sequential
sequential
sequential
sequential
sequential
read'
read'
read'
read'
read'
read'
read'
read'
read'
read'
read'
read'
ela=
ela=
ela=
ela=
ela=
ela=
ela=
ela=
ela=
ela=
ela=
ela=
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
55
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
56
Background ORADEBUG
_________________________________
_________________________________
COUNT(*)
---------11015
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
System altered.
SQL>
_________________________________
_________________________________
COUNT(*)
---------23
SQL> oradebug event 10046 trace name context off
Statement processed.
_________________________________
57
_________________________________
_________________________________
/oracle/<SID>/saptrace/background
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
WAIT
#0:
#0:
#0:
#0:
#0:
#0:
#0:
#0:
#0:
#0:
#0:
#0:
#0:
#0:
#0:
#0:
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
58
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
59
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
60
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
61
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
62
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
63
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
64
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
65
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
66
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
67
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
68
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
69
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
70
OS Debugging Methods
truss
_________________________________
_________________________________
_________________________________
_________________________________
sar
_________________________________
strace
_________________________________
_________________________________
_________________________________
vmstat
_________________________________
_________________________________
71
ping
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
72
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
73
_________________________________
_________________________________
Benefits:
f Does not use the single ST Enqueue, which can cause
performance issues
f Reduces DBAs workload by configuring auto allocate or
uniform extent sizes
Disadvantages:
f Still uses pct_used and pct_free, which are not efficient
f Concurrent inserts are still sent to the same free block on
the freelist
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
74
_________________________________
ASSM tablespaces
_________________________________
Benefits:
f Same benefits as listed on previous slide for LMTS
f No longer uses the pct_used and pct_free; instead, manages
the block filling based on the percentages
f Concurrent inserts are automatically sent to different blocks
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
75
AUM
_________________________________
_________________________________
PGA tuning
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
76
Auto extend
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
77
SPFILE
_________________________________
Using the SPFILE aids in the managing of the database and the
parameters that are changed
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
Tables that do not have LONG or LONG RAW columns can now
be reorganized online using DBMS_REDEFINITION package.
This method is based on materialized views technology.
_________________________________
_________________________________
_________________________________
78
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
79
Resources
Oracle/SAP Newsletter
_________________________________
_________________________________
www.oracle.com/newsletters/sap/current.html
_________________________________
Wait Events
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
80
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
81
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
82
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
_________________________________
83
Notes:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
Notes:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
Notes:
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
Wellesley Information Services, 990 Washington Street, Suite 308, Dedham, MA 02026