Académique Documents
Professionnel Documents
Culture Documents
#.2
http://www.oraperf.com
#.3
Tuning Methodology
Machine
Run
queue (CPU)
reduce CPU usage or add CPUs Reduce memory usage or add memory
Paging
Oracle
Tune waits
#.4
For Analysis
CPU Time
For
Wait Time >> CPU Time, need top waits detailed analysis of some waits detailed analysis of some waits
Copyright 2006 Kyle Hailey
#.5
II 10g ASH
OEM ASH Report : ashrpt.sql Custom queries on v$active_session_history
#.6
I Statspack
Look at Top 5 Timed Events
Top 5 Timed Events ~~~~~~~~~~~~~~~~~~ % Total Event Waits Time (s) Call Time -------------------------------------------- ------------ ------------------buffer busy waits 2,748 250 78.72 CPU time 32 10.16 free buffer waits 1,588 15 4.63 write complete waits 10 8 2.51 log buffer space 306 5 1.51
#.7
#.8
#.9
#.10
II 10g v$active_session_history
The best source Only in 10g Can simulate in any version since v7
II Querying ASH
#.11
Top 5 Timed Events Count ------------------------------------ --------log file parallel write 8 CPU 7 select 3 event as "TOP 5 Timed Events", control file parallel write null event 3 cnt as "Count" from ( log file sync 2 select decode(ash.session_state, 'ON CPU','CPU',en.name) event , count(decode(ash.session_state, 'ON CPU','CPU',en.name)) cnt from v$active_session_history ash, v$event_name en where en.event# (+) = ash.event# and SAMPLE_TIME > sysdate - (5/(24*60)) group by decode(ash.session_state,'ON CPU','CPU',en.name) order by count(decode(ash.session_state, 'ON CPU','CPU',en.name)) desc ) where rownum < 6; Copyright 2006 Kyle Hailey
#.12
SID EVENT
------------------------236 db file scattered read 245 db file scattered read 245 db file scattered read 248 db file scattered read
P1 P2 P3
--- --- --3 35291 16 1 13646 2 1 8457 7 1 42226 8
from v$ash
#.13
II ASH Report
ASH report @?/rdbms/admin/ashrpt.sql Pick interval over last 7 days !
1) General info 2) Top User Events *** 3) Top Background Events 4) Top Event P1/P2/P3 Values 5) Top Service/Module 6) Top Client IDs 7) Top SQL Command Types 8) Top SQL Statements *** 9) Top SQL using literals 10) Top Sessions *** 11) Top Blocking Sessions 12) Top Sessions running PQs 13) Top DB Objects 14) Top DB Files 15) Top Latches 16) Activity Over Time ***
#.14
III V$session_wait
Moment in Time data
select decode(w.wait_time, 0, w.event , 'CPU') as "TOP 5 Timed Events, count(*) from v$session s, v$session_wait w where w.sid=s.sid and s.status='ACTIVE' and s.type='USER' and w.event not in ('jobq slave wait', 'rdbms ipc reply') group by decode(w.wait_time, 0, w.event , 'CPU') order by count(*) desc; Copyright 2006 Kyle Hailey
#.15
III V$session_wait
Top 5 Timed Events ----------------------------------enq: US contention CPU buffer busy waits latch: row cache objects COUNT ---------4 3 1 1
#.16
III V$session_wait
col status for a35 select s.sid, s.sql_hash_value, decode(w.wait_time, 0, w.event , 'CPU') as status, w.p1, w.p2, w.p3 from v$session s, v$session_wait w where w.sid=s.sid and s.status='ACTIVE' and s.type='USER' and w.event not in ('jobq slave wait', 'rdbms ipc reply');
Copyright 2006 Kyle Hailey
#.17
III V$session_wait
Moment in Time data
SID SQL_HASH STATUS ---------- --------------------------------------------234 82347421 CPU 235 3336613934 enq: US - contention 236 1772152815 enq: US - contention 238 2750335498 enq: US - contention 240 343101472 enq: US - contention 246 1782401401 enq: US - contention 248 3333220954 CPU 252 323960517 enq: US - contention 260 1272059733 CPU P1 P2 P3 ------------------- ---------1431502854 39 0 1431502854 44 0 1431502854 42 0 1431502854 44 0 1431502854 44 0 1431502854 44 0 1650815232 1 0 1431502854 44 0 1431502854 44 0
#.18
#.19
Background Waits
Filter Out Background Waits
Statspack ASH : SESSION_TYPE='FOREGROUND V$session_wait : type='USER'
#.20
Background Waits
ASH
Avoid
#.21
Idle Waits
Filter Out 10g
where
9i
Create
#.22
#.23
RAC Waits
You are on your own Check documentation If you are not using RAC then no worries 10g
#.24
10g
select name from v$event_name where wait_class='Scheduler';
#.25
#.26
buffer# file# name|mode segment# name|mode cache id handle address object address handle address
block# object # usn<<16 | slot mode pin address lock address record length
#.27
Wait Tree
Buffer Cache I/O Locks Waits
Library Cache
Redo SQL*Net Undo
Copyright 2006 Kyle Hailey
Top 12 Waits
NAME Count % Total
#.29
db file sequential read 23,850.00 log file sync 20,594.00 db file scattered read 15,505.00 latch free 11,078.00 enqueue 7,732.00 SQL*Net more data from client 7,510.00 direct path read 5,840.00 direct path write 4,868.00 buffer busy waits 4,589.00 SQL*Net more data to client 3,805.00 log buffer space 2,990.00 log file switch completion 2,878.00
11.67% 10.08% 7.59% 5.42% 3.78% 3.67% 2.86% 2.38% 2.25% 1.86% 1.46% 1.41%
Anjo Kolk
#.30
Copyright 2006 Kyle Hailey minus OPS, RAC, PQ, Resource Mgr
Waits 1-9
1.
2. 3. 4. 5. 6. 7. 8. 9.
#.31
latch free need p1,p2,p3 enqueue need p1,p2,p3 and SQL SQL*Net more data from client
Usually OK, reduce data transferred, possible Network problems
Waits 10-18
10. SQL*Net more data to client
Usually OK, reduce amount of data transferred, possible Network tuning needed
#.32
15. io done
Io done by IO slaves, oracleIxxx could also be an idle wait sort of worthless
Waits 19-27
19. write complete waits
Increase buffer cache (or tune DBWR)
#.33
#.34
Waits 28-36
28. file identify
Keep log files open, reduce checkpoints
#.35
Difficult Waits
Latches Locks Buffer Busy Row Cache Lock
#.36
Concepts: Latches
Protect areas of memory from concurrent use Light weight locks
Usually
a held in a bit in memory Often supported by atomic processor call Fast and cheap Gone if memory is lost
to a datablock
Exclusive Generally
Sharing
#.37
Finding Latches
latch free
Covers many latches, find the problem latch by 1. select name from v$latchname where latch# = p1;
OR
2.
latch: cache buffers chains latch: shared pool latch: library cache
Copyright 2006 Kyle Hailey
#.38
library cache
kks stats row cache object library cache lock library cache pin enqueues enqueue hash chains
2,242,805
263,464 434,844 666,668 741,963 133,577 133,751
79,554
2,842 955 734 635 373 89
15,198
1,774 147 54 42 40 19
66,497
1,152 816 680 593 333 70
0
0 0 0 0 0 0
Important Latches
Cache Buffers Chains
#.39
Hot blocks, distribute activity, reduce update time, avoid select for update
Too much activity , uses multiple buffer caches and/or increse LRU latches
Shared Pool
Hard Parsing
Use bind variables Uses cursor_sharing=force Increase shared pool size if reloads are high
Avoid invalidations
Hold cursors open Use session_cached_cursors
Soft Parsing
Use cursor_space_for_time
Copyright 2006 Kyle Hailey
#.40
Concepts: Locks
Enqueue wait covers all locks pre 10 Protect data against concurrent changes Lock info written into data structures
Block
Finding Locks
Statspack not much help V$session_wait needs lots of decoding
P1
#.41
#.42
Locks 10g
10g breaks Enqueues out
enq: enq: enq: enq: enq: enq:
HW TM TX TX TX UL
contention contention allocate ITL entry index contention row lock contention contention
#.43
Locks : TM & TX
select * from v$lock where type in ('TX', 'TM'); SID --151 135 151 135 TY ID1 ID2 LMODE REQUEST CTIME BLOCK -- ---------- ---------- ----- ------- ----- ----TX 589855 1592 0 6 4049 0 TM 53737 0 3 0 4058 0 TM 53737 0 3 0 4049 0 TX 589855 1592 6 0 4058 1
#.44
Segment Header add free Lists (with Datablock) Free List add free lists groups
Copyright 2006 Kyle Hailey
#.45
Class
Waits
#.46
look at v$waitstat
Class Time/Count
SQL> select
* from v$waitstat;
CLASS COUNT TIME ------------------ ---------- ---------data block 1 1 segment header 0 0 free list 0 0 undo header 0 0 undo block 0 0
Copyright 2006 Kyle Hailey
#.47
#.48
#.49
Areas of Contention
Buffer Cache Disk I/O Library Cache Redo SQL*Net Undo
We will go through these areas and the wait events that are relevant to them.