Professional Documents
Culture Documents
Intro : About me
Oracle DBA / consultant / trainer since 2000
Oracle ACE since 2010
Blogger - http://oracleprof.blogspot.com/
Agenda
Performance tuning
Define a metrics to measure
best metrics are related to time
and business activities
Compare performance with system baseline
and business goals
IT
USER
Tuning goals
99 % of response time for SQL/business
transaction has to be X seconds, rest has to be
maximum Y seconds
For 99 % of executions - X number of
rows/business operations have to be
processed in Y seconds
DBTime is money
DB Time
Oracle doc Database time represents the total
time spent in database calls, and is an indicator of
the total instance workload
Sum of CPU time and not idle wait time (IO and
others)
ASH samples counts = DB Time in seconds
(proof in DB Time Oracle Performance Tuning: Theory and Practice by
Graham Wood, John Beresniewicz)
DB Time
DB Time increase when system load increase
number of active sessions increase
number of calls increase
Time
t0
t1
Time
t0
2
t1
2
No of samples
t1
13
14
17
18
20
Value
SESSION_STATE
ON CPU
WAIT_TIME
21
Value
SESSION_STATE
WAITING
WAIT_TIME
TIME_WAITED
22
EVENT
TIME_WAITED
------------------------------- ----------enq: TX - row lock contention
0
enq: TX - row lock contention
0
enq: TX - row lock contention
0
enq: TX - row lock contention
0
enq: TX - row lock contention
enq: TX - row lock contention
0
21295426
23
Cluster
Application
Queuing
Scheduler
Network
Commit
24
ASH - Math
Use count(*) for calculate wait or ON CPU
time
Group by session_id, sql_id, client_id, etc....
As ASH is a sample do not use time_waited
column in calculations:
sum(time_waited)
avg(time_waited)
etc.
25
ASH - Math
Example of query Profile of SQL queries from ASH
select
sql_id,
event,
count(*) cnt
from v$active_session_history
group by sql_id,event
26
select count(*)
from v$active_session_history ...
select count(*) * 10
from dba_hist_active_sess_history ...
27
session_id
user_id
program
module
action
machine
client_id
sql_id
pl/sql
blocking_session
object
file
etc.
28
Top SQL
select sql_id,
round((count(*) / sum(count(*)) over
())*100,2) ActPct
from v$active_session_history
where sql_id is not null
and sample_time > sysdate5/1440
group by sql_id
order by ActPct
29
Top Session
select session_id, round((count(*) /
sum(count(*)) over ())*100,2) ActPct
from v$active_session_history
where
sample_time > sysdate5/1440
group by session_id
order by ActPct desc
30
Top program
select program, round((count(*) /
sum(count(*)) over ())*100,2) ActPct
from v$active_session_history
where
sample_time > sysdate5/1440
group by program
order by ActPct desc
31
Blocking session
select
session_id, event, blocking_session
from v$active_session_history
where
blocking_session is not null
and sample_time > sysdate - 5/1440;
32
OEM 11g
33
34
35
36
37
38
ASH availability
39
Other options
3rd party products DB Optimizer, I3, Spotlight
Free solution Simulating-ASH
http://ashmasters.com/
https://sourceforge.net/projects/orasash
https://github.com/pioro/orasash
Interactive ASH tool with statistics
Snapper v. 3.0. by Tanel Poder
40
Case study
41
Case study
AverageTransactions/s - 80.23
AverageTransactions/s - 98.18
42
Case Study
43
46
Load profile
select * from (
select
decode(session_state,'WAITING',event,'ON CPU'),
count(*) cnt,
count(*) / (sum(count(*)) over ()) * 100 pct
from dba_hist_active_sess_history
where
sample_time between X and Y
group by
decode(session_state,'WAITING',event,'ON CPU')
order by cnt desc
) where rownum <= 5;
47
Load profile
EVENT
CNT
PCT
------------------------------ ---------- ------enq: US - contention
8059
53.65
ON CPU
3107
20.68
db file sequential read
645
4.29
latch: undo global data
536
3.57
enq: TX - row lock contention
446
2.97
ON CPU
db file sequential read
enq: US - contention
LNS wait on SENDREQ
LGWR-LNS wait on channel
1347
524
365
215
201
38.38
14.93
10.40
6.13
5.73
48
49
gur9jrbxvbvur
No sql_opname filter
50
Lazy clean up
select *
from table(dbms_xplan.display_cursor
('62fbdqwqht3x1',null));
SQL_ID 62fbdqwqht3x1, child number 0
------------------------------------select KVAL_SEQUENCE.nextval from dual
Plan hash value: 3926490670
---------------------|
0 | SELECT STATEMENT |
|
1 | SEQUENCE
|
|
2 |
FAST DUAL
|
52
53
54
SQL_ID
SQL_PLAN_HASH_VALUE
------------- ------------------dyuz1k3bdr36s
760792886
dyuz1k3bdr36s
760792886
dyuz1k3bdr36s
760792886
dyuz1k3bdr36s
2913971644
dyuz1k3bdr36s
2913971644
dyuz1k3bdr36s
dyuz1k3bdr36s
dyuz1k3bdr36s
dyuz1k3bdr36s
dyuz1k3bdr36s
2913971644
760792886
2913971644
760792886
760792886
55
17324251
51
56
57
58
Q&A
59