Rmougashmastershort 140207171440 Phpapp02
Rmougashmastershort 140207171440 Phpapp02
Rmougashmastershort 140207171440 Phpapp02
Kyle Hailey
http://kylehailey.com
[email protected]
2/14/2014
Disastrously difficult
SQL
Sessions
OEM
ASH
Sampling
Waits
Where does the OEM data come from ?
OEM
ASH
Sampling
Waits
Connect as SYSDBA
@?/rdbms/admin/spcreate.sql
Run
Exec statspack.snap;
Generate Reports
@?/rdbms/admin/spreport.sql
(AWR : @?/rdbms/admin/awrrpt.sql )
Session details x 3
Tablespace I/O
File I/O
File I/O histogram
Buffer pool
Instance Recovery
Buffer pool advisory
Buffer busy waits
Various PGA
summaries
PGA histogram
PGA advisory
PGA allocation
summary
PGA allocation top N
Enqueue (lock)
activity
Undo stats x 2
Latch activity
Latch miss details
Statspack Method
Who/When
Summary
days
Big Picture
Waits
Latch Free
Top 5 Timed Events
~~~~~~~~~~~~~~~~~~
% Total
Event
Waits
Time (s) Ela Time
-------------------------------------------- ------------ ----------- -------latch free
9,652
760
66.10
CPU time
248
21.62
PL/SQL lock timer
41
123
10.72
SQL*Net message from dblink
681
14
1.22
log file parallel write
128
1
.13
-------------------------------------------------------------
8,435,488
55,645
58,626
Sleeps 1->4
-----------0/0/0/0/0
81537/1330/4
7/1/0
1,294 54375/1247/2
2/1/0
1 6/1/0/0/0
Who is waiting
Who is blocking
What is the SQL
What is the row?
Who blocks?
What object?
what is the SQL?
OEM
ASH
Sampling
Waits
Example
Look at Statspack:
What do we do?
How do we solve buffer busy wait
Need:
SQL
Sessions
Objects
How do we get that information?
Not from Statspack or AWR
But from v$session
v$session_wait prior to 10g
V$session
Shows who is waiting
For example on buffer busy waits
Data only exists while waits are happening
Data includes
Sql
Session
Object
Type of buffer busy wait
File and block involved in buffer busy wait
Sample Query
select
nvl(s.username,s.program) username,
s.sid sid,
s.serial# serial,
SQL identifier
s.sql_hash_value sql_hash_value,
substr(decode(w.wait_time,
Waiting or on CPU?
0, w.event,
'ON CPU'),1,15) event ,
w.p1 p1,
w.p2 p2,
w.p3 p3
from
v$session
s,
v$session_wait w
where w.sid=s.sid
and s.status='ACTIVE'
and s.type='USER';
Sampling Output
USERNAME
---------SYS
SYS
STARGUS
(CJQ0)
SID
----64
58
71
9
SERIAL
-------8717
19467
6251
1
SQL_HASH_V
---------4116021597
961168820
1311875676
0
EVENT
-------------------PL/SQL lock timer
ON CPU
direct path write
rdbms ipc message
P1
-------300
16508152
201
500
P2
-------0
1
2155902
0
P3
---0
0
127
0
v$event_name
Or documentation
N
--1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
CLASS
-----------------data block
sort block
save undo block
segment header
save undo header
free list
extent map
1st level bmb
2nd level bmb
3rd level bmb
bitmap block
bitmap index block
file header block
unused
system undo header
system undo block
undo header
undo block
COUNT(*)
FILEN
BLOCKN
---------- -------- -------1
11
90644
2
11
90651
3
11
98233
1
11
104767
3
11
113291
1
11
119842
1
11
119856
3
11
121632
1
11
126334
Find Object
column segment_name format a30
COUNT(*)
FILEN
BLOCKN
---------- -------- -------1
11
126334
select
owner,
segment_name,
segment_type,
block_id, blocks+block_id
from dba_extents
where file_id = 11
and 126334 between block_id AND block_id + blocks-1;
OWNER
SEGMENT_NAME
SEGMENT_TY
BLOCK_ID BLOCKS+BLOCK_ID
---------- ------------------ ---------- ---------- --------------SYSTEM
TOTO1
TABLE
125201
127249
What SQL ?
SQL> select count(*), sql_hash_value
2 from v$ash
3 where event='buffer busy waits'
4 group by hash_value;
COUNT(*)
---------3423
SQL_HASH_VALUE
-------------558666863
SQL Statement ?
select sql_text
from v$sqltext
where hash_value=558666863;
SQL_TEXT
----------------------------------------------------INSERT into toto1 values (:b1,lpad('a',1000,'a'))
Insert statement
Problem on a data block on
table toto1
Solution: Freelists or ASSM
4 Sessions running
Insert into toto1
values (null, a);
Commit;
S1
S2
OBJN
----------54962 TOTO1
54962 TOTO1
S3
S4
2. Reverse Keys
Sampling Summary
Sampling v$session
When a problem, shows the root causes
Active Session History (ASH)
v$active_session_history
OEM
ASH
Sampling
Waits
v$active_session_history
When
Session
State
Wait
SQL
Duration
SAMPLE_ID
SAMPLE_TIME
NUMBER
TIMESTAMP(3)
SESSION_ID
SESSION_SERIAL#
USER_ID
SERVICE_HASH
SESSION_TYPE
PROGRAM
MODULE
ACTION
CLIENT_ID
NUMBER
NUMBER
NUMBER
NUMBER
VARCHAR2(10)
VARCHAR2(64)
VARCHAR2(48)
VARCHAR2(32)
VARCHAR2(64)
SESSION_STATE
WAIT_TIME
EVENT
EVENT_ID
EVENT#
SEQ#
P1
P2
P3
WAIT_TIME
TIME_WAITED
CURRENT_OBJ#
CURRENT_FILE#
CURRENT_BLOCK#
SQL_ID
SQL_CHILD_NUMBER
SQL_PLAN_HASH_VALUE
SQL_OPCODE
QC_SESSION_ID
QC_INSTANCE_ID
VARCHAR2(7)
NUMBER
VARCHAR2(64)
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER0
VARCHAR2(13)
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
TIME_WAITED
NUMBER
SAMPLE_TIME
Time
SESSION_ID
Session
State
EVENT
Wait
SQL_ID
SQL
USER_ID
SERVICE_HASH
(OE,GL,HR)
MODULE.ACTION
CLIENT_ID
(PLSQL tagging)
(identifying users in session pool)
PROGRAM
SQL_ID
QC_SESSION_ID
QC_INSTANCE_ID
Select
from
v$active_session_history
where
session_state= ON CPU and
SAMPLE_TIME > sysdate (5/(24*60))
group by
session_id
order by
count(*) desc;
SESSION_ID
COUNT(*)
---------- ---------257
299
263
62
256
32
264
9
277
3
Select
session_id,
count(*)/(5*60) COUNT/ELAPSED=AAS
100*(count(*)/(5*60) ) -- % active
from
v$active_session_history
where
session_state= ON CPU and
SAMPLE_TIME > sysdate (5/(24*60))
group by
Last 5 minutes
session_id
order by
count(*) desc;
AAS/100 = % active
SESSION_ID
AAS
%busy
---------- ---------- --------257
.99
99
263
.21
21
256
.11
11
264
.03
3
277
.01
1
0 10 range
0-1
SESSION_ID
COUNT(*)
% Bar
---------- ---------- ---------- -----------257
299
99 |**********|
263
62
21 |**
|
256
32
11 |*
|
264
9
3 |
|
277
3
1 |
|
258
1
0 |
|
280
1
0 |
|
from
v$active_session_history
where
session_state=WAITING and
SAMPLE_TIME > SYSDATE - (5/(24*60))
group by
session_id
order by
count(*) desc;
"CPU",
"TOTAL"
SQL_ID
CPU
WAITING
IO
TOTAL
------------- ---------- ---------- ---------- ---------4c1xvq9ufwcjc
23386
0
0
23386
6wjw6rz5uvbp3
99
0
23
122
968dm8hr9qd03
97
0
22
119
938jp5gasmrah
90
0
25
115
cv8xnv81kf582
42
0
9
51
6p9bzu19v965k
21
0
0
21
5zu8pxnun66bu
15
0
0
15
db2jr13nup72v
9
0
0
9
7ks5gnj38hghv
8
0
0
8
Top Session
select select
ash.session_id,
ash.session_id,
ash.session_serial#,
ash.session_serial#,
ash.user_id,
ash.user_id,
ash.program,
ash.program,
sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",
sum(decode(ash.session_state,'ON CPU',1,0)) - "CPU",
sum(decode(ash.session_state,'WAITING',1,0))
sum(decode(ash.session_state,'WAITING',1,0)) sum(decode(ash.session_state,'WAITING',
sum(decode(ash.session_state,'WAITING',
decode(en.wait_class,'User
I/O',1, 0 ), 0)) "WAITING" ,
decode(en.wait_class,'User I/O',1, 0 ), 0)) "WAITING" ,
sum(decode(ash.session_state,'WAITING',
decode(en.wait_class,'User
I/O',1, 0 ), 0)) "IO" ,
sum(decode(ash.session_state,'WAITING',
sum(decode(session_state,'ON
CPU',1,1))
decode(en.wait_class,'User
I/O',1, 0 ), 0))"TOTAL"
"IO" ,
from v$active_session_history
ash,
sum(decode(session_state,'ON
CPU',1,1)) "TOTAL"
v$event_name
en
from v$active_session_history
ash,
where en.event# = ash.event#
v$event_name en
group by session_id,user_id,session_serial#,program
where
en.event# = ash.event#
order by
sum(decode(session_state,'ON
CPU',1,1))
group by session_id,user_id,session_serial#,program
order
sum(decode(session_state,'ON
Nobytime
window specified CPU',1,1))
ASH
topsession ,
v$session s, Connected?
user$
u User name
Top Session
Finding a Rogue User
STATUS
SESSION_ID NAME
PROGRAM
CPU
WAITING
IO
--------------- ---------- ---------- ------------------------- ----- ---------- ---CONNECTED
247 CPU_Monger ChMgr304.exe
11704
0
0
CONNECTED
277 SYS
oracle@labsfrh903 (LGWR)
14
19
0
CONNECTED
278 SYS
oracle@labsfrh903 (DBW0)
29
0
0
CONNECTED
276 SYS
oracle@labsfrh903 (CKPT)
18
9
0
CONNECTED
280 SYS
oracle@labsfrh903 (PMON)
20
0
0
DISCONNECTED
255 SYSTEM
Executor.exe
11
4
5
DISCONNECTED
257 SYSTEM
Executor.exe
13
0
3
DISCONNECTED
255 SYSTEM
Executor.exe
14
0
2
DISCONNECTED
257 SYSTEM
Executor.exe
13
0
3
Key to ASH
Difficulties
Pitfalls
Solution
Keys to ASH
1. Seconds =
COUNT(*)
2. AAS =
COUNT(*) / Elapsed
Solution
repository of pre-written queries
ASHRPT
@?/rdbms/admin/ashrpt.sql
Exec ASH_REPORT_TEXT/HTML
ASHRPT
ASH Report For TESTDB/testdb
DB Name
DB Id
Instance
Inst Num Release
RAC Host
------------ ----------- ------------ -------- ----------- --- -----------TESTDB
2371570538 testdb
1 10.2.0.1.0 NO sdbe604a
CPUs
SGA Size
Buffer Cache
Shared Pool
ASH Buffer Size
---- ------------------ ------------------ ------------------ -----------------2
1,000M (100%)
468M (46.8%)
112M (11.2%)
4.0M (0.4%)
Analysis Begin Time:
21-Apr-06 12:00:01
Analysis End Time:
21-Apr-06 12:05:01
Elapsed Time:
5.0 (mins)
Sample Count:
3,716
Average Active Sessions:
12.39
Avg. Active Session per CPU:
6.19
Report Target:
None specified
Top User Events
DB/Inst: TESTDB/testdb (Apr 21 12:00 to 12:05)
Avg Active
Event
Event Class
% Activity
Sessions
----------------------------------- --------------- ---------- ---------CPU + Wait for CPU
CPU
67.98
8.42
enq: TX - row lock contention
Application
23.98
2.97
buffer busy waits
Concurrency
4.66
0.58
latch: cache buffers chains
Concurrency
2.26
0.28
ASH RPT
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 ***
ASH Masters
intro to github
1.Load Charts
2.Wait Analysis locks, latches, bbw
3.SQL elapsed times
4.Top sql, session, wait, procedure, object
5.I/O size, object
Extra: Latency * - not from ASH, but important
1. Load Charts
How to get a quick overview of all the data in the ASH ?
Top waits
History from dba_hist_active_sess_history
AAS
------2.24
6.67
2.59
1.26
1.38
1.74
.99
1.22
1.66
1.08
.83
1.74
2.47
6.59
GRAPH
---------------------++--------2--++++------2---------++--------2---++----2
+++---2
++------- 2
+---2
++----2
++------ 2
+---2
+--2
++------- 2
++--------2---+++-------2----------
What is this ?
AAS
------.33
2.24
6.67
2.59
1.26
1.38
1.74
.99
1.22
1.66
1.08
.83
1.74
2.47
6.59
1.95
3.08
GRAPH
---------------------+2
++--------2--++++------2---------++--------2---++----2
+++---2
++------- 2
+---2
++----2
++------ 2
+---2
+--2
++------- 2
++--------2---+++-------2---------++++++--- 2
+++++-----2------
- = WAIT
+ = CPU
which waits ?
WAITS
Counts
, sum(decode(session_state,'ON CPU',1,0)) cpu
, sum(decode(session_state,'WAITING',1,0)) waits
ID
CPU
Waits
Group by
AAS
rpad('+',round(( cpu/&v_secs)*&v_bars),'+) ||
rpad('-',round((waits/&v_secs)*&v_bars),'-') ||
1.
2.
3.
+++++----1
+++++-----
||
||
+++++-----
First half
of line
core count
2nd half
of line
select
to_char(to_date( trunc((id*&v_secs)/ (24*60*60)) || ' ' || -- Julian days
mod((id*&v_secs), (24*60*60))
-- seconds in the day
, 'J SSSSS' ), 'MON DD YYYY HH24:MI:SS') start_time,
substr( substr(
rpad('+',round(( cpu/&v_secs)*&v_bars),'+) ||
rpad('-',round((waits/&v_secs)*&v_bars),'-') ||
rpad(' ',p.value * &v_bars,' ) ,0,(p.value * &v_bars)) ||
p.value ||
substr(
rpad('+',round(( cpu/&v_secs)*&v_bars),'+) ||
rpad('-',round((waits/&v_secs)*&v_bars),'-') ||
rpad(' ',p.value * &v_bars,' '), (p.value * &v_bars))
,0,&v_graph) graph
from (
select trunc((to_char(sample_time,'J')*(24*60*60)+to_char(sample_time,'SSSSS'))/&v_secs) id
, sum(decode(session_state,'ON CPU',1,0)) cpu
CPU
, sum(decode(session_state,'WAITING',1,0)) waits
from v$active_session_history ash
WAITS
group by
trunc((to_char(sample_time,'J')*(24*60*60)+to_char(sample_time,'SSSSS'))/&v_secs)
) aveact,
v$parameter p
where p.name='cpu_count'
order by id
/
Bar
ID
GRAPH
NOV 03 2013 22:03:00 ++---1-----NOV 03 2013 22:04:00 +++--1------NOV 03 2013 22:05:00 +----1NOV 03 2013 22:06:00 +++--1--
When waiting,
which are the top waits ?
ID
EVENT
EVENT_COUNT
---------- ------------------------------- ----------3537592817 control file heartbeat
2
3537592818 ADR block file read
1
3537592818 ARCH wait for process start 3
3
3537592818 ON CPU
9
3537592818 control file parallel write
4
id
event
Ran
CPU WAITS
k
ID EVENT
RANK PCT
---------- ----------------------------- ---- --- ---- ----3537592818 ON CPU
1 .290 9
0
3537592818 db file sequential read
2 .161 0
5
3537592818 log file switch (checkpoint i 3 .161 0
5
3537592818 control file parallel write 4 .129 0
4
3537592818 ARCH wait for process start 5 .096 0
3
3537592818 ADR block file read
6 .032 0
1
Rank
ash_graph_waits.sql
select id
, round(max(decode(top.rank,1,pct,null)),2) fpct
, max(
decode(top.rank,1,decode(top.event,'ON CPU','CPU',event),null)) first
, round(max(decode(top.rank,2,pct,null)),2) spct
, max(
decode(top.rank,2,decode(top.event,'ON CPU','CPU',event),null)) second
, sum(waits) waits
, sum(cpu) cpu
ID
FPCT FIRST
SPCT SECOND
WAITS
CPU
---------- ----- --------------- ----- --------------- ---------- -----3537592817 1.00 control file he
2
0
3537592818 .29 CPU
.16 db file sequent
22
9
3537592819 .72 control file pa .14 CPU
37
6
3537592820 .75 CPU
.25 control file pa
1
3
3537592821 .91 CPU
.09 direct path rea
1 10
3537592823 .75 CPU
.25 db file paralle
1
3
PCT2 SECOND
GRAPH
15 20:00 63 CPU
4
4
++ooo----
15 22:00 35 CPU
++++++++++oooooooooo4ooooooooooooooo--
++++++oooooooooooo--4---------
+++ooooooooooo
+ooo
+oo
o = I/O
+ = cpu
- = wait
1. Load Charts :
dba_hist_active_sess_history?
dba_hist_active_sess_history
Week of ASH data !!
Only 1 in 10 v$active_session_history rows kept
Has DBID
Can query different databases in same repository
Fast, in memory
V$ACTIVE_SESSION_HISTORY +
slower
DBA_HIST_ACTIVE_SESS_HISTORY combine
ash_graph_waits_histash.sql minute buckets
MIN
0
57
ash_sql_elapsed_hist.sql
with histogram of execution times
SQL_ID
CT
MX
MN
AV
1
2 3 4
------------- ---------- ---------- ---------- -------- ------ ------ ----- ----- ----5k7vccwjr5ahd
2653
1963
0 33.4 2623 15 8
ds8cz0fb8w147
161
2531
13 273.8 136 18 5
4
1
3
1
ash_sql_elapsed_hist_longestid.sql
execution id of longest running query
SQL_ID
CT
MX MN
AV MAX_RUN_TIME
LONGEST_SQ
1
2 3 4 5
------------- ------ ---------- ---- -------- ----------------------------------- ---------- ------ ------ ----- ---- --2spgk3k0f7quz 251
29607 0 546.0 11-04-12 12:11:47 11-04-12 20:25:14 16781748
247
2 0 0 2
990m08w8xav7s 591
7681 0 52.0 11-04-13 00:39:27 11-04-13 02:47:28 16786685
587
0 0 2 2
Executions
MX
AV
MIN
26
15
3068
3106
133.1
767.7
0
57
8r5wuxk1dprhr
39
3510
841.0
24
0w5uu5kngyyty
21
3652
442.3
0hbv80w9ypy0n
161
71fwb4n6a92fv
49
0bujgc94rg3fj
64dqhdkkw63fd
604
4089
4481
4929
1183.9
676.9
24.7
1083
7147
7.2
990m08w8xav7s
591
7681
51.8
2n5369dsuvn5a
16 10472
2spgk3k0f7quz
251 29607
0
30
0
0
0
5726.8
303
546.1
36pd759xym9tc
12 37934 23861.9
497wh6n7hu14f
49 69438
5498.2
1391
0
select
sql_id,
id
sql_exec_id,
Seconds running
(cast(sample_time as date) cast(sql_exec_start as date)) * (60*60*24) tm
from
v$active_session_history
where sql_exec_id is not null
SQL_ID
SQL_EXEC_ID
------------- ----------- ---------acc988uzvjmmt 16777220
acc988uzvjmmt 16777220
acc988uzvjmmt 16777220
acc988uzvjmmt 16777220
TM
3
2
1
0
now select max seconds for each sql_exec_id
each SQL_ID
max
min
average
execution times
COUNT(*)
MX
AV
MIN
26
15
3068
3106
133.1
767.7
0
57
8r5wuxk1dprhr
39
3510
841.0
24
0w5uu5kngyyty
21
3652
442.3
0hbv80w9ypy0n
161
71fwb4n6a92fv
49
0bujgc94rg3fj
64dqhdkkw63fd
604
4089
4481
4929
1083
7147
1183.9
676.9
24.7
0
30
7.2
CT
MX
MN
AV
------------- ---------- ------- ------- -------- ------ ------ ----- ----- -401ayw4r7n6kz
1983
30hzp85f3qtxj
179
3029
9k86k2zvht9pt
3052
bnddu47dqmzqd
10
3138
gc7khrc2mx86m
3618
8rua4c9agcqkb
978
820
1983 1983.0
29
111.0
3052 3052.0
68
732.3
3618 3618.0
0
72.7
820/5 = 164
830 executions
115 executions
21 executions
9 executions
2 executions
177
21
92
7
0
1
0
830 116
MX MN
AV MAX_RUN_TIME
LONGEST_SQ
------------- ---- ------ ---- ------ ----------------------------------- ---------- ------ ------ ----- ---- --30hzp85f3qtxj 179
177
C61wk6d7ssxxc 20
13
769uu28qm4thw 17
1427
10
Fuzcbdt08xjcd 74
Bkv51bug8ag7c 29
307
1wgsn7mmf6kqc 131
299
3b7q0hd1q8pw0 17
288
1v6yyfy630rkj 13
1t715k5p9uxxx 50
95
16
A98fbc69py0us 11
0g53kf4gr3vrg 25
5 14
start
End
51
AWR fails
Block type
Object
File
ash_bbw.sql
OBJN
OTYPE FILEN BLOCKN SQL_ID
BLOCK_TYPE
------------------------- ----------- ------ ------------- -----------53218 BBW_INDEX_VAL_I INDEX 1 64826 97dgthz60u28d data block 1
53218 BBW_INDEX_VAL_I INDEX 1 64826 gypmcfzruu249 data block 1
53218 BBW_INDEX_VAL_I INDEX 1 64826 2vd1w5kgnfa5n data block 1
53218 BBW_INDEX_VAL_I INDEX 1 64826 3p3qncvp2juxs data block 1
53218 BBW_INDEX_VAL_I INDEX 1 64826 6avm49ys4k7t6 data block 1
OTYPE
-----TABLE
TABLE
TABLE
TABLE
SQL_ID
------------8gz51m9hg5yuf
8gz51m9hg5yuf
8gz51m9hg5yuf
8gz51m9hg5yuf
CLASS
-----------------data block
data block
segment header
data block
NAME
P1
P2
P3
----------------- ----- ------ ----buffer busy waits file# block# class#
CLASS
-----------------data block
sort block
save undo block
segment header
save undo header
free list
extent map
1st level bmb
2nd level bmb
3rd level bmb
bitmap block
bitmap index block
file header block
unused
system undo header
system undo block
undo header
undo block
Who is waiting?
Who is blocking?
What is the SQL?
What is the row?
Not in AWR report
v$active_session_history
Waiter
SESSION_ID
SESSION_SERIAL#
USER_ID
Blocker
- BLOCKING_SESSION
- BLOCKING_SESSION_STATUS
- BLOCKING_SESSION_SERIAL#
Object
CURRENT_OBJ#
CURRENT_FILE#
CURRENT_BLOCK#
SQL Waiting
- SQL_ID
Meaning
varies
3. Waits: enq TX 4
Mode 4, unique key
ST
----10:39
10:39
10:39
10:39
EVENT
---------------------enq: TX - row lock c
enq: TX - row lock c
enq: TX - row lock c
enq: TX - row lock c
SID LM
P2
P3 OBJ
OTYPE FN BLOCKN SQL_ID
--- --- ------ ---- ----- ----- --- ------ -141
4 655406 6672 -1
0
0 bjvx94vnxtxgv
141
4 655406 6672 -1
0
0 bjvx94vnxtxgv
141
4 655406 6672 -1
0
0 bjvx94vnxtxgv
141
4 655406 6672 -1
0
0 bjvx94vnxtxgv
ST
----10:41
10:41
10:41
EVENT
---------------------enq: TX - row lock c
enq: TX - row lock c
enq: TX - row lock c
SID LM
P2
P3 OBJ
--- --- ------ ---- ----144
4 179681 7074 CHILD
144
4 179681 7074 CHILD
144
4 179681 7074 CHILD
BSID
158
158
158
158
BSID
BSID
1
1
1
Mode 4, bitmap
ST
----10:41
10:41
10:41
10:41
EVENT
---------------------enq: TX - row lock c
enq: TX - row lock c
enq: TX - row lock c
enq: TX - row lock c
SID LM
P2
P3 OBJ
--- --- ------ ---- ----143
4 966081 4598 I1
143
4 966081 4598 I1
143
4 966081 4598 I1
143
4 966081 4598 I1
144
144
144
144
4. Top
Procedure
ash_top_procedure.sql
Session
ash_top_session.sql - wait, I/O and CPU time
SQL
ash_top_sql.sql - wait, I/O and CPU time
ash_top_sql_w_top_obj.sql - with top OBJ per SQL
ALL_PROCEDURES view
object_id = plsql_object_id
subprogram_id = plsql_subprogram_id
2/14/2014
98
SID NAME
PROGRAM
CPU WAITING
IO TOTAL
54 SYS
oracle@source (J000)
1227
DISCONNECTED
57 SYS
oracle@source (J001)
725
160
DISCONNECTED
71 SYS
DISCONNECTED
67 SYSTEM
LAB128.exe
18
60
903
36
187
182 148
517
CONNECTED
10 SYS
oracle@source (DBW0)
267
171
438
CONNECTED
11 SYS
oracle@source (LGWR)
10
357
367
DISCONNECTED
44 SYS
CONNECTED
53 SYSTEM
CONNECTED
36 SYSMAN
OMS
129
6
114
631
158
15
33
162
120
276
4. Top: SQL
SQL_ID
ash_top_sql.sql
PLAN_HASH TYPE
CPU WAIT
IO TOTAL
9345
9 84277 93631
82040
850 82896
1186 78728
46995
2068
22345 489
422
45
3196 50236
1 24914 26983
313 23147
0 19655 20077
14272
4. Top: SQL
SQL_ID
ash_top_sql_w_top_obj.sql
------------- ----------- ------- ---- ----- ---- ------- ------- -------------dr1fpksws4nv9 3458999899 SELECT 3791
0 3791
5 3690 60
0 1864
PS_F_ABS_EXPTN_CAL
0 2038
0 1864
PS_TAX_BALANCE
6 1364 1487 98
PS_PAY_DEDUCTION
0 1375 1414 87
PS_PAY_CHECK
PS_F_TIALAST_HIST
39
14 1377 64
5. I/O : iosql.sql
I/O by SQL and top Objects for that sql
TCNT SQL_ID
P1 TABLESPACE_NAME
2 0 -1 0
7 AWR
1 SYSTEM
1 0 6342 WRH$_SQL_PLAN_PK
11 0 6339 WRH$_SQL_PLAN
14 52tyrgvbph5fc 14 077259 77259
2 SYSAUX
2 SYSAUX
7 AWR
iosql.sql
select
sum(cnt) over ( partition by io.sql_id order by sql_id ) tcnt,
io.sql_id, io.cnt cnt, io.aas aas, io.objn objn, io.obj obj, io.p1 p1,
f.tablespace_name tablespace_name
from
(
select
sql_id,
count(*) cnt,
round(count(*)/(&v_minutes*60),2) aas,
CURRENT_OBJ# objn,
nvl(o.object_name,decode(CURRENT_OBJ#,-1,0,CURRENT_OBJ#)) obj,
o.object_type otype,
ash.p1
from v$active_session_history ash
,all_objects o
where ( event like 'db file s%' or event like 'direct%' )
and o.object_id (+)= ash.CURRENT_OBJ#
and sample_time > sysdate - &v_minutes/(60*24)
group by
CURRENT_OBJ#,o.object_name ,o.object_type , ash.p1, sql_id
) io,
dba_data_files f
where
f.file_id = io.p1
Order by tcnt, io.sql_id, io.cnt
/
Extra : Latency
Cant get latency from: TIME_WAITED
So tempting
latency_waitclassmetric.sql each 60 seconds WAIT_CLASS
V$WAITCLASSMETRIC
AVG_IO_MS
---------2.032
latency: latency_eventmetric.sql
Last 60 seconds
NAME
TIME_WAITED WAIT_COUNT
3.856
2.809
12
6
4.682
0
0
0
0
3.213
AVGMS
AVG_MS
6.133
01-MAY-13 21:57
.642
01-MAY-13 23:00
.199
02-MAY-13 00:00
.023
02-MAY-13 01:00
.031
02-MAY-13 02:00
.006
02-MAY-13 03:00
.017
02-MAY-13 04:00
.015
02-MAY-13 05:00
.013
02-MAY-13 06:00
.019
02-MAY-13 07:00
.017
latency_system_event.sql
DBA_HIST_SYSTEM_EVENT
DBA_HIST_SNAPSHOT
Input event name
END