Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Kyle Hailey
http://perfvision.com
#.2
ASH
Whole New Paradigm in
Technology
The Power of ASH lies in
Simplifying Performance Tuning
I couldn’t
Often, even
I didn’tdecipher
understandStats Pack half
statspack’s 1000+the time
lines
Copyright 2006 Kyle Hailey
#.11
Oh no … it’s 3am my manager
calls
“why is the database hanging?!”
Who did it?
Where did the SQL get blocked?
What if the bottlenecked started 5 minutes
after my last Stats Pack?
Cheaper
Richer Multidimensional Data
Identifies
SQL
Sessions
Objects
Machine
User
SQL
v$sql
Could be 10000s
Takes out latches that compete with other sql executions
Objects
V$segstat 9i+
Could be 1000s of objects
Expensive !
Copyright 2006 Kyle Hailey
#.17
? ? ? ? ? TIME
Session States
Latency
Work Contention
IDLE
Example : SQL*Net Message from Client
10g select name
from v$event_name
where wait_class='Idle';
58 Rows
CPU
ASH: SESSION_STATE = “ON CPU”
ASH: wait_time > 0
10g: v$session
9i: v$session_wait
IO
ASH: SESSION_STATE=‘WAITING’
&
WAITING
ASH: SESSION_STATE=‘WAITING’
ASH: WAIT_TIME <= 0
WAIT_CLASS
1. Administrative
2. Application
3. Cluster
4. Commit
5. Concurrency
6. Configuration
7. Network
8. Other
9. Scheduler
10. System I/O
800+ WAIT
Session 2
Session 3
Session 4
SAMPLE_ID
SAMPLE_TIME
NUMBER
TIMESTAMP(3) When
SESSION_ID NUMBER
SESSION_SERIAL# NUMBER Session
USER_ID NUMBER
SERVICE_HASH NUMBER
SESSION_TYPE VARCHAR2(10)
PROGRAM VARCHAR2(64)
MODULE VARCHAR2(48)
ACTION VARCHAR2(32)
CLIENT_ID VARCHAR2(64)
SESSION_STATE
WAIT_TIME
VARCHAR2(7)
NUMBER
State
EVENT
EVENT_ID
VARCHAR2(64)
NUMBER
Wait
EVENT# NUMBER
SEQ# NUMBER
P1 NUMBER
P2 NUMBER
P3 NUMBER
WAIT_TIME NUMBER
TIME_WAITED NUMBER
CURRENT_OBJ# NUMBER
CURRENT_FILE# NUMBER
CURRENT_BLOCK# NUMBER0
SQL_ID
SQL_CHILD_NUMBER
VARCHAR2(13)
NUMBER
SQL
SQL_PLAN_HASH_VALUE NUMBER
SQL_OPCODE NUMBER
QC_SESSION_ID NUMBER
QC_INSTANCE_ID NUMBER
TIME_WAITED Copyright 2006 Kyle Hailey
NUMBER
Duration
#.29
SAMPLE_TIME When
SESSION_STATE State
SESSION_ID Session
SQL_ID SQL
EVENT Wait
TIME_WAITED Duration
No machine
(32 columns in ASH)
Copyright 2006 Kyle Hailey
#.31
Groupings – Top Consumer
SESSION_ID
SESSION_SERIAL# (signal SID reuse)
SESSION_TYPE (FOREGROUND,BACKGROUND)
USER_ID (SYS, SYSTEM, SCOTT etc)
SERVICE_HASH (OE,GL,HR)
MODULE.ACTION(PLSQL tagging)
CLIENT_ID (identifying users in a session pool)
PROGRAM (SQL, JDBC, Forms etc)
SQL_ID
QC_SESSION_ID - Query Coordinator
QC_INSTANCE_ID – RAC
EVENT + P1, P2, P3
CURRENT_OBJ#
CURRENT_FILE#
CURRENT_BLOCK#
Copyright 2006 Kyle Hailey
#.32
Select
session_id,
count(*)
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;
Copyright 2006 Kyle Hailey
#.33
SESSION_ID COUNT(*)
SESSION_ID COUNT(*)
----------
---------- ----------
----------
265 256
265 264 25615
264 257 1512
271 12
257 276 12 1
271 12
276 1
Select
session_id,
count(*)
from
v$active_session_history
where
session_state=‘WAITING’ and
SAMPLE_TIME > SYSDATE - (5/(24*60))
group by
session_id
order by
count(*) desc;
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
sum(decode(ash.session_state,'WAITING',1,0))
CPU',1,0)) "CPU", -
sum(decode(ash.session_state,'WAITING',
decode(en.wait_class,'User I/O',1, 0 ), 0)) "WAITING" ,
sum(decode(ash.session_state,'WAITING',1,0))
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)) "TOTAL"
decode(en.wait_class,'User I/O',1, 0 ), 0))
from v$active_session_history
"WAITING" , ash,
v$event_name en
sum(decode(ash.session_state,'WAITING',
where en.event# = ash.event#
decode(en.wait_class,'User I/O',1, 0 ), 0))
group by"IO"
session_id,user_id,session_serial#,program
,
order by sum(decode(session_state,'ON
sum(decode(session_state,'ONCPU',1,1)) CPU',1,1))
"TOTAL" Copyright 2006 Kyle Hailey
#.40
Solution - Graphics
Session 2
Session 3
Session 4
TIME
#.49
15 Second Averages
Idle Users
Statistics
are more expensive
have lag time
lack clear identification of culprits
Slight Lags
Counters
ASH – In Memory
Collects active session data only
History v$session_wait + v$session + extras
Circular Buffer - 1M to 128M (~2% of SGA)
Flushed every hour to disk or when buffer 2/3
full (it protects itself so you can relax)
ASH Sizing …
ASH buffer
Insert one direction
Select reads
backwards - Touch up wait times
-No latching
-No read consistency
-Index on time Insert point
v$session_wait
v$active_session_history
V$session_wait_history
DBA_HIST_ACTIVE_SESS_HISTORY
wrh$active_session_history
Copyright 2006 Kyle Hailey
ASH Tables #.66
SESSION_STATE
Waiting,
on CPU
Based on WAIT_TIME
Oradebug
Dump to trace file
SQL>
SQL> oradebug
oradebug dumpashdump
ash 5 5
SQL> Alter session set events ‘immediate
SQL> Alter session set events ‘immediate
tracenameashdump
tracename ashdump level 5’;
level 5’;
level 5 = # of minutes
loader file rdbms/demo/ashldr.ctl
INIT.ORA
statistics_level = Typical (default)
06/11/08 70
#.71
10.2 Extras
10gR2 add fields to ASH
Blocking Session Id, serial# and state ***
XID, transaction ID
RAC event Fixup
Plan Hash Fix up
10gR1 - during parsing no plan, good way to find parsing
problems
10gR2 – get plan hash fixup – good but lose some ability to find
parsing problems
Wait Class, needed this for grouping
Force_matching_signature – sql profile id
ALL_PROCEDURES
where object_id = plsql_object_id
and subprogram_id = plsql_subprogram_id
06/11/08 72
#.73
PLSQL Tracking
calling_code SQL_ID COUNT(*)
----------------------------------------------- ----------
Package/Procedure/SQL
ORDERENTRY.NEWORDER
tracking 10.2.0.3
0uuqgjq7k12nf 258
ORDERENTRY.NEWCUSTOMER 0bzhqhhj9mpaa 262
ORDERENTRY.BROWSEANDUPDATEORDERS 41zu158rqf4kf 301
ORDERENTRY.NEWORDER 0yas01u2p9ch4 569
PARSE_SAME 3vjxpmhhzngu4 874
ORDERENTRY.BROWSEANDUPDATEORDERS 05s4vdwsf5802 1669
select
object_name package||.|| procedure_name, sql_id, count(*)
from v$active_session_history ash,
all_procedures procs
where
ash.PLSQL_ENTRY_OBJECT_ID = procs.object_id
and ash.PLSQL_ENTRY_SUBPROGRAM_ID = procs.SUBPROGRAM_ID
06/11/08 73
11g ASH extras #.74
SQL execution ID
Is this same execution as last sample?
can see how long sql has been running
Simulating ASH
ASH is new in 10g
ASH data exist since V7
Need Diagnostic Pack License
Collect it yourself
SASH – Simulated ASH
http://perfvision.com/sash.php
Graphical Monitor
http://perfvision.com/ashmon.php
Sampling
Sampling is the future
Took clean vision to create
Bit of a leap of faith
Less Accurate but more powerful than past
Inaccuracies unimportant for the most part
Feasible since version 7
You can implement it yourself
Graphics are the only way to full harness the
power
Summary
To solve hard problems you need Sampling
If you have 10g and a license you can use
V$active_session_history
OEM 10g (can access some 9 sampling)
?/rdbms/admim/ashrpt.sql
ASH Summary
Faster, Cheaper, instant (no lag) …
but most importantly