Transcript
Page 1: Oracle 10g Performance: chapter 01 ash

#.1

ASHASH –– Active Session HistoryActive Session History

Feel the PowerFeel the Power

Kyle Haileyhttp://perfvision.com

Page 2: Oracle 10g Performance: chapter 01 ash

#.2Copyright 2006 Kyle Hailey

Why should you care?Why should you care?

Because ASH can Change your life …

10g immediately Accessible Geeks: Via scripts in SQL Managers : Graphical OEM

Stuck on Oracle 7,8,9 ?… my apologies because 10g rocks, but …no worries, the data is accessible for you too via scripts

http://perfvision.com/sash.php

Page 3: Oracle 10g Performance: chapter 01 ash

#.3Copyright 2006 Kyle Hailey

Revolution and an EvolutionRevolution and an Evolution

Oracle 6 … ie the dark ages … there was once the Cache Buffer Hit Ratio

Oracle 7 … turned the lights on … Wait Events … hallelujah I can see the light

Oracle 10g … ASH has landed

(like the wheels on the suitcases)

Page 4: Oracle 10g Performance: chapter 01 ash

#.4Copyright 2006 Kyle Hailey

Sampling Sampling New ParadigmNew Paradigm

Clear Vision of the future Use new sampling technology Lets go of the need to know 100% Statistical approximation

Cheaper Richer Multidimensional Data Identifies

SQL Sessions Objects Machine User

Page 5: Oracle 10g Performance: chapter 01 ash

#.5Copyright 2006 Kyle Hailey

Identify Players before ASHIdentify Players before ASH

Sessions v$sesstat, v$session_event# sessions x (# wait events + statistics)Example (150 x (800+200) = 150,000 )

SQLv$sql

Could be 10000s Takes out latches that compete with other sql executions

ObjectsV$segstat 9i+

Could be 1000s of objects

Expensive !

Also files v$filestat

Page 6: Oracle 10g Performance: chapter 01 ash

#.6Copyright 2006 Kyle Hailey

ASHASH Intelligence for the new Millennium Intelligence for the new Millennium

Intelligently Collects Data Samples once a second Collects active sessions only Collects Session/SQL/Wait More activity, more data collected Less activity, less data collected

Those old methods collected everything Obfuscated the problem, too many statistics too late Costly Too Granular – once an hour ?! Give me a break

Collects fine grain multidimensional data

Page 7: Oracle 10g Performance: chapter 01 ash

#.7Copyright 2006 Kyle Hailey

ASHASH Fields FieldsSQL> v$active_session_history Name Null? Type

----------------------------------------- -------- ----------------------------

SAMPLE_ID NUMBER SAMPLE_TIME TIMESTAMP(3) SESSION_ID NUMBER SESSION_SERIAL# NUMBER USER_ID NUMBER SQL_ID VARCHAR2(13) SQL_CHILD_NUMBER NUMBER SQL_PLAN_HASH_VALUE NUMBER SQL_OPCODE NUMBER SERVICE_HASH NUMBER SESSION_TYPE VARCHAR2(10) SESSION_STATE VARCHAR2(7) QC_SESSION_ID NUMBER QC_INSTANCE_ID NUMBER EVENT VARCHAR2(64) EVENT_ID NUMBER EVENT# NUMBER SEQ# NUMBER P1 NUMBER P2 NUMBER P3 NUMBER WAIT_TIME NUMBER TIME_WAITED NUMBER CURRENT_OBJ# NUMBER CURRENT_FILE# NUMBER CURRENT_BLOCK# NUMBER PROGRAM VARCHAR2(48) MODULE VARCHAR2(48) ACTION VARCHAR2(32) CLIENT_ID VARCHAR2(64

Page 8: Oracle 10g Performance: chapter 01 ash

#.8Copyright 2006 Kyle Hailey

v$active_session_historyv$active_session_history

SESSION_ID NUMBER SESSION_SERIAL# NUMBER USER_ID NUMBER SERVICE_HASH NUMBER SESSION_TYPE VARCHAR2(10) PROGRAM VARCHAR2(64) MODULE VARCHAR2(48) ACTION VARCHAR2(32) CLIENT_ID VARCHAR2(64)

EVENT VARCHAR2(64) EVENT_ID NUMBER 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 VARCHAR2(13) SQL_CHILD_NUMBER NUMBER SQL_PLAN_HASH_VALUE NUMBER SQL_OPCODE NUMBER QC_SESSION_ID NUMBER QC_INSTANCE_ID NUMBER

SAMPLE_ID NUMBER SAMPLE_TIME TIMESTAMP(3)

SESSION_STATE VARCHAR2(7) WAIT_TIME NUMBER

TIME_WAITED NUMBER

When

Session

SQL

Wait

State

Duration

Page 9: Oracle 10g Performance: chapter 01 ash

#.9Copyright 2006 Kyle Hailey

Primary Fields of Primary Fields of ASHASH

SESSION_ID

EVENT

SQL_ID

SAMPLE_TIME Time

Session

SQL

Wait

SESSION_STATE State

Activity : Who, What, When, How

Who

What

When

How

Page 10: Oracle 10g Performance: chapter 01 ash

#.10Copyright 2006 Kyle Hailey

Amazing things YOU can doAmazing things YOU can do

Top Consumers Session User Object Module.Action Program Service Client Wait

X

Top Resources• CPU• Waits

• Event (800*)• I/O

• File• Block

• Time

(32 columns in ASH 10.1)

Top SQL SQL ID Plan Child#

X

And Aggregated over any time Period

Page 11: Oracle 10g Performance: chapter 01 ash

#.11

Multi-dimensionalMulti-dimensional

06/05/0806/05/08

25 34 36 38 45 63 65 87 25 34 36 38 45 63 65 87

F1qcyh20550cfF1qcyh20550cf

fj6gjgsshtxyxfj6gjgsshtxyx

0cjsxw5ndqdbc0cjsxw5ndqdbc

8t8as9usk11qw8t8as9usk11qw

dr1rkrznhh95bdr1rkrznhh95b

10dkqv3kr8xa510dkqv3kr8xa5

38zhkf4jdyff438zhkf4jdyff4

298wmz1kxjs1m298wmz1kxjs1m

CPUCPUEnq: TX – row lock contention

Enq: TX – row lock contention

SQL*Net break/reset to client

SQL*Net break/reset to client

db file scattered read

db file scattered read

db file sequential read

db file sequential read

IOIO

Application

Application

SQLSQL

SessionsSessions

Waits

Waits

Statistics

Statistics

Service Service

ScottScott SystemSystemUserUser

Program Program

SysSys

SqlplusSqlplus ToadToad

GLGL OEOE

Package

Procedure

Plan

Child #

Page 12: Oracle 10g Performance: chapter 01 ash

#.12Copyright 2006 Kyle Hailey

Groupings – Top ConsumerGroupings – Top ConsumerSESSION_IDSESSION_SERIAL# (identify SID reuse)SESSION_TYPE (FOREGROUND,BACKGROUND)

CURRENT_OBJ#CURRENT_FILE#CURRENT_BLOCK#

USER_ID (SYS, SYSTEM, SCOTT etc)

SERVICE_HASH (OE,GL,HR)

PROGRAM (SQL, JDBC, Forms etc)

MODULE.ACTION (PLSQL tagging)

CLIENT_ID (identifying users in session pool)

SQL_IDQC_SESSION_ID (Query Coordinator)QC_INSTANCE_ID (RAC)

EVENT + P1, P2, P3

Page 13: Oracle 10g Performance: chapter 01 ash

#.13Copyright 2006 Kyle Hailey

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;

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;

Top CPU SessionTop CPU Session

Top CPU consuming Session in last 5 minutes

Who is the rogue session ?Who is the rogue session ?

Page 14: Oracle 10g Performance: chapter 01 ash

#.14Copyright 2006 Kyle Hailey

Results Top CPU SessionResults Top CPU Session

SESSION_ID COUNT(*) ---------- ---------- 257 299 263 62 256 32 264 9 277 3 258 1

SESSION_ID COUNT(*) ---------- ---------- 257 299 263 62 256 32 264 9 277 3 258 1

Page 15: Oracle 10g Performance: chapter 01 ash

#.15Copyright 2006 Kyle Hailey

CPU with Bars CPU with Bars

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 | |

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 | |

Bar shows 10% incrementsBar shows 10% increments

Page 16: Oracle 10g Performance: chapter 01 ash

#.16Copyright 2006 Kyle Hailey

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;

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 Waiting Session Top Waiting Session

Top Waiting Session in last 5 minutes

Page 17: Oracle 10g Performance: chapter 01 ash

#.17Copyright 2006 Kyle Hailey

SESSION_ID COUNT(*)---------- ---------- 272 224 254 8 249 5 276 5 277 4 270 1

SESSION_ID COUNT(*)---------- ---------- 272 224 254 8 249 5 276 5 277 4 270 1

Top Waiting Session ResultsTop Waiting Session Results

Page 18: Oracle 10g Performance: chapter 01 ash

#.18Copyright 2006 Kyle Hailey

Top SQL from Top SQL from ASHASH

select

ash.SQL_ID ,

sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",

sum(decode(ash.session_state,'WAITING',1,0)) -

sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) "WAIT" ,

sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) "IO" ,

sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"

from v$active_session_history ash,

v$event_name en

where SQL_ID is not NULL and en.event#=ash.event#

group by sql_id

order by sum(decode(session_state,'ON CPU',1,1)) desc

select

ash.SQL_ID ,

sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",

sum(decode(ash.session_state,'WAITING',1,0)) -

sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) "WAIT" ,

sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) "IO" ,

sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"

from v$active_session_history ash,

v$event_name en

where SQL_ID is not NULL and en.event#=ash.event#

group by sql_id

order by sum(decode(session_state,'ON CPU',1,1)) desc

select

ash.SQL_ID ,

sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",

sum(decode(ash.session_state,'WAITING',1,0)) -

sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) "WAIT" ,

sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) "IO" ,

sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"

from v$active_session_history ash,

v$event_name en

where SQL_ID is not NULL and en.event#=ash.event#

group by sql_id

order by sum(decode(session_state,'ON CPU',1,1)) desc

select

ash.SQL_ID ,

sum(decode(ash.session_state,'ON CPU',1,0)) "CPU",

sum(decode(ash.session_state,'WAITING',1,0)) -

sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) "WAIT" ,

sum(decode(ash.session_state,'WAITING', decode(en.wait_class, 'User I/O',1,0),0)) "IO" ,

sum(decode(ash.session_state,'ON CPU',1,1)) "TOTAL"

from v$active_session_history ash,

v$event_name en

where SQL_ID is not NULL and en.event#=ash.event#

group by sql_id

order by sum(decode(session_state,'ON CPU',1,1)) desc

Page 19: Oracle 10g Performance: chapter 01 ash

#.19Copyright 2006 Kyle Hailey

Top SQL from Top SQL from ASHASH Results Results

SQL_ID CPU WAITING IO TOTAL------------- ---------- ---------- ---------- ----------4c1xvq9ufwcjc 23386 0 0 233866wjw6rz5uvbp3 99 0 23 122968dm8hr9qd03 97 0 22 119938jp5gasmrah 90 0 25 115cv8xnv81kf582 42 0 9 516p9bzu19v965k 21 0 0 215zu8pxnun66bu 15 0 0 15db2jr13nup72v 9 0 0 97ks5gnj38hghv 8 0 0 8

SQL_ID CPU WAITING IO TOTAL------------- ---------- ---------- ---------- ----------4c1xvq9ufwcjc 23386 0 0 233866wjw6rz5uvbp3 99 0 23 122968dm8hr9qd03 97 0 22 119938jp5gasmrah 90 0 25 115cv8xnv81kf582 42 0 9 516p9bzu19v965k 21 0 0 215zu8pxnun66bu 15 0 0 15db2jr13nup72v 9 0 0 97ks5gnj38hghv 8 0 0 8

Page 20: Oracle 10g Performance: chapter 01 ash

#.20Copyright 2006 Kyle Hailey

Top SessionTop Session

select ash.session_id, ash.session_serial#, ash.user_id, ash.program, sum(decode(ash.session_state,'ON CPU',1,0)) "CPU", sum(decode(ash.session_state,'WAITING',1,0)) - sum(decode(ash.session_state,'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(session_state,'ON CPU',1,1)) "TOTAL"from v$active_session_history ash, v$event_name enwhere en.event# = ash.event#group by session_id,user_id,session_serial#,programorder by sum(decode(session_state,'ON CPU',1,1))

select ash.session_id, ash.session_serial#, ash.user_id, ash.program, sum(decode(ash.session_state,'ON CPU',1,0)) "CPU", sum(decode(ash.session_state,'WAITING',1,0)) - sum(decode(ash.session_state,'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(session_state,'ON CPU',1,1)) "TOTAL"from v$active_session_history ash, v$event_name enwhere en.event# = ash.event#group by session_id,user_id,session_serial#,programorder by sum(decode(session_state,'ON CPU',1,1))

select ash.session_id, ash.session_serial#, ash.user_id, ash.program, sum(decode(ash.session_state,'ON CPU',1,0)) "CPU", sum(decode(ash.session_state,'WAITING',1,0)) - sum(decode(ash.session_state,'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(session_state,'ON CPU',1,1)) "TOTAL"from v$active_session_history ash, v$event_name enwhere en.event# = ash.event#group by session_id,user_id,session_serial#,programorder by sum(decode(session_state,'ON CPU',1,1))

Page 21: Oracle 10g Performance: chapter 01 ash

#.21Copyright 2006 Kyle Hailey

Top Session ResultsTop Session Results

SESSION_ID SERIAL# USER_ID PROGRAM CPU WAITING IO

---------- ------- ---------- ------------------------- ------- ---------- ----------

247 61970 1 sqlplus 11698 0 0

277 1 0 oracle@labsfrh903 (LGWR) 14 21 0

276 1 0 oracle@labsfrh903 (CKPT) 19 10 0

278 1 0 oracle@labsfrh903 (DBW0) 29 0 0

280 1 0 oracle@labsfrh903 (PMON) 19 0 0

254 22617 5 Executor.exe 13 0 3

255 12877 5 Executor.exe 11 0 5

257 33729 5 Executor.exe 15 0 1

255 13417 5 Executor.exe 14 0 2

SESSION_ID SERIAL# USER_ID PROGRAM CPU WAITING IO

---------- ------- ---------- ------------------------- ------- ---------- ----------

247 61970 1 sqlplus 11698 0 0

277 1 0 oracle@labsfrh903 (LGWR) 14 21 0

276 1 0 oracle@labsfrh903 (CKPT) 19 10 0

278 1 0 oracle@labsfrh903 (DBW0) 29 0 0

280 1 0 oracle@labsfrh903 (PMON) 19 0 0

254 22617 5 Executor.exe 13 0 3

255 12877 5 Executor.exe 11 0 5

257 33729 5 Executor.exe 15 0 1

255 13417 5 Executor.exe 14 0 2

Page 22: Oracle 10g Performance: chapter 01 ash

#.22Copyright 2006 Kyle Hailey

Top Session w/ UsernameTop Session w/ Usernameselect

decode(nvl(to_char(s.sid),-1),-1,'DISCONNECTED','CONNECTED')

"STATUS",

topsession.session_id "SESSION_ID",

u.name "NAME",

topsession.program "PROGRAM",

max(topsession.CPU) "CPU",

max(topsession.WAITING) "WAITING",

max(topsession.IO) "IO",

max(topsession.TOTAL) "TOTAL"

from ( {previous query} ) topsession,

v$session s,

user$ u

where

u.user# =topsession.user_id and

/* outer join to v$session because the session might be disconnected */

topsession.session_id = s.sid (+) and

topsession.session_serial# = s.serial# (+)

group by topsession.session_id, topsession.session_serial#, topsession.user_id,

topsession.program, s.username,s.sid,s.paddr,u.name

order by max(topsession.TOTAL) desc

select

decode(nvl(to_char(s.sid),-1),-1,'DISCONNECTED','CONNECTED')

"STATUS",

topsession.session_id "SESSION_ID",

u.name "NAME",

topsession.program "PROGRAM",

max(topsession.CPU) "CPU",

max(topsession.WAITING) "WAITING",

max(topsession.IO) "IO",

max(topsession.TOTAL) "TOTAL"

from ( {previous query} ) topsession,

v$session s,

user$ u

where

u.user# =topsession.user_id and

/* outer join to v$session because the session might be disconnected */

topsession.session_id = s.sid (+) and

topsession.session_serial# = s.serial# (+)

group by topsession.session_id, topsession.session_serial#, topsession.user_id,

topsession.program, s.username,s.sid,s.paddr,u.name

order by max(topsession.TOTAL) desc

Page 23: Oracle 10g Performance: chapter 01 ash

#.23Copyright 2006 Kyle Hailey

Top Session Top Session Finding a Rogue UserFinding a Rogue User

STATUS SESSION_ID NAME PROGRAM CPU WAITING IO--------------- ---------- ---------- ------------------------- ----- ---------- ----CONNECTED 247 CPU_Monger ChMgr304.exe 11704 0 0CONNECTED 277 SYS oracle@labsfrh903 (LGWR) 14 19 0CONNECTED 278 SYS oracle@labsfrh903 (DBW0) 29 0 0CONNECTED 276 SYS oracle@labsfrh903 (CKPT) 18 9 0CONNECTED 280 SYS oracle@labsfrh903 (PMON) 20 0 0DISCONNECTED 255 SYSTEM Executor.exe 11 4 5DISCONNECTED 257 SYSTEM Executor.exe 13 0 3DISCONNECTED 255 SYSTEM Executor.exe 14 0 2DISCONNECTED 257 SYSTEM Executor.exe 13 0 3

STATUS SESSION_ID NAME PROGRAM CPU WAITING IO--------------- ---------- ---------- ------------------------- ----- ---------- ----CONNECTED 247 CPU_Monger ChMgr304.exe 11704 0 0CONNECTED 277 SYS oracle@labsfrh903 (LGWR) 14 19 0CONNECTED 278 SYS oracle@labsfrh903 (DBW0) 29 0 0CONNECTED 276 SYS oracle@labsfrh903 (CKPT) 18 9 0CONNECTED 280 SYS oracle@labsfrh903 (PMON) 20 0 0DISCONNECTED 255 SYSTEM Executor.exe 11 4 5DISCONNECTED 257 SYSTEM Executor.exe 13 0 3DISCONNECTED 255 SYSTEM Executor.exe 14 0 2DISCONNECTED 257 SYSTEM Executor.exe 13 0 3

Page 24: Oracle 10g Performance: chapter 01 ash

#.24Copyright 2006 Kyle Hailey

Many Ways to Attack ProblemsMany Ways to Attack Problems

Confusing

How to Attack the problem? Top SQL?

Top wait for that SQL? Top Waiting Session ?

Top Waits for that Session Top Waits for Database?

Top Session waiting for that wait Top SQL for that wait

Solution - Graphics

Page 25: Oracle 10g Performance: chapter 01 ash

#.25Copyright 2006 Kyle Hailey

Mining Data is Non TrivialMining Data is Non Trivial

Many Dimensions to consider Constantly Varying time frames Luckily 10g automates all of this functionality.

collects all of the dataanalyses all the wait events reports on bottlenecks supplies solutions

Graphics add tremendous ease and power

Page 26: Oracle 10g Performance: chapter 01 ash

#.26Copyright 2006 Kyle Hailey

OEM Perf PageOEM Perf Page

Page 27: Oracle 10g Performance: chapter 01 ash

#.27Copyright 2006 Kyle Hailey

ASH Sampling CheapASH Sampling Cheap

Cost 1. With PL/SQL it’s less that 1 % CPU with 10 average

active sessions

2. DMA - direct memory attach to SGA Using C code 200x Cheaper

3. ASH in 10g should be even cheaper than DMA because it’s done in the kernel

Size Circular Buffer - 1M to 128M (~2% of SGA)

Avg row around 150bytes 3600 secs in an hour ~ ½ Meg per Active Session per hour

Page 28: Oracle 10g Performance: chapter 01 ash

#.28Copyright 2006 Kyle Hailey

How ASH worksHow ASH works

V$session_wait+ v$session + extras

MMON/MMNL

v$active_session_history

wrh$_active_session_history

Only writes out 1 in 10 rows via direct path inserts

MMON - manageability monitor, AWRM000 – MMON background slave, runs snapshotsMMNL - MMON lite, flushes ASH to disk

Page 29: Oracle 10g Performance: chapter 01 ash

#.29Copyright 2006 Kyle Hailey

Select reads backwards

-No latching

-Index on time

-No read consistency

Insert point

ASH bufferASH buffer

Insert one direction

Touch up wait times

Page 30: Oracle 10g Performance: chapter 01 ash

#.30Copyright 2006 Kyle Hailey

Family of ASH TablesFamily of ASH Tables

v$session

v$active_session_history

wrh$active_session_history

v$session_wait_history

DBA_HIST_ACTIVE_SESS_HISTORY

Real time

~2 hours

1 week

Last 10 waits

(before 10g v$session_wait)

Page 31: Oracle 10g Performance: chapter 01 ash

#.31Copyright 2006 Kyle Hailey

OradebugOradebug

Dump to trace file

SQL> oradebug dump ash 5

SQL> Alter session set events ‘immediate tracename ashdump level 5’;

level 5 = # of minutesloader file rdbms/demo/ashldr.ctl

SQL> oradebug dump ashdump 5

SQL> Alter session set events ‘immediate

trace name ashdump level 5’;

Page 32: Oracle 10g Performance: chapter 01 ash

#.32Copyright 2006 Kyle Hailey

INIT.ORAINIT.ORAstatistics_level = Typical (default)

PARAMETER SESSION_VALUE INSTANCE_VAL

----------------------- ---------- ------------

_ash_sampling_interval 1000 1000

milliseconds

_ash_size 1048618 1048618

ASH buffer size

_ash_enable TRUE TRUE

Turn on/off ASH sampling, flushing and the V$ views on ASH

_ash_disk_write_enable TRUE TRUE

Flush to disk

_ash_disk_filter_ratio 10 10

write 1 in 10 points

_ash_sample_all FALSE FALSE

Sample including idle waits

Page 33: Oracle 10g Performance: chapter 01 ash

#.33

10.2 ASH Extras10.2 ASH Extras

Blocking Session !BLOCKING_SESSION BLOCKING_SESSION_STATUS BLOCKING_SESSION_SERIAL#

3304/10/23

RAC event FixupRAC event Fixup

Plan Hash Fix up Plan Hash Fix up

10gR1 - during parsing no plan, 10gR1 - during parsing no plan, good way to find parsing good way to find parsing problemsproblems

10gR2 – get plan hash fixup – 10gR2 – get plan hash fixup – good but lose some ability to find good but lose some ability to find parsing problemsparsing problems

Parameter Names P1TEXT , P2TEXT, P3TEXT

Wait GroupingWAIT_CLASS WAIT_CLASS_ID XID

FORCE_MATCHING_SIGNATURECursor sharing

Page 34: Oracle 10g Performance: chapter 01 ash

#.34

10.2.0.3 ASH Extras10.2.0.3 ASH Extras

PLSQL_ENTRY_OBJECT_ID

PLSQL_ENTRY_SUBPROGRAM_ID

PLSQL_OBJECT_ID

PLSQL_SUBPROGRAM_ID

3404/10/23

ALL_PROCEDURESALL_PROCEDURES where object_id = plsql_object_id where object_id = plsql_object_id and subprogram_id = plsql_subprogram_id and subprogram_id = plsql_subprogram_id

Page 35: Oracle 10g Performance: chapter 01 ash

#.353504/10/23

PLSQL TrackingPLSQL TrackingPackage/Procedure/SQL tracking 10.2.0.3

calling_code SQL_ID COUNT(*)----------------------------------------------- ----------ORDERENTRY.NEWORDER 0uuqgjq7k12nf 258ORDERENTRY.NEWCUSTOMER 0bzhqhhj9mpaa 262ORDERENTRY.BROWSEANDUPDATEORDERS 41zu158rqf4kf 301ORDERENTRY.NEWORDER 0yas01u2p9ch4 569PARSE_SAME 3vjxpmhhzngu4 874ORDERENTRY.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

Page 36: Oracle 10g Performance: chapter 01 ash

#.36Copyright 2006 Kyle Hailey

11.1g ASH extras11.1g ASH extras

SQL ElapsedSQL Elapsed SQL_EXEC_ID SQL_EXEC_START

 IN_CONNECTION_MGMT IN_PARSE IN_HARD_PARSE IN_SQL_EXECUTION IN_PLSQL_EXECUTION IN_PLSQL_RPC IN_PLSQL_COMPILATION IN_JAVA_EXECUTION IN_BIND IN_CURSOR_CLOSE

SQL_PLAN_LINE_ID SQL_PLAN_OPERATION SQL_PLAN_OPTIONS

CURRENT_ROW#  EVENT#  QC_SESSION_SERIAL# CONSUMER_GROUP_ID FLAGS

ETCETC

Operation bit vector – non timed opsOperation bit vector – non timed ops

SQL Row Source SQL Row Source

 REMOTE_INSTANCE#Which instance requested block?Which instance requested block?

TOP_LEVEL_SQL_ID

TOP_LEVEL_SQL_OPCODE

Recursive SQLRecursive SQL

Page 37: Oracle 10g Performance: chapter 01 ash

#.37Copyright 2006 Kyle Hailey

11.2g ASH extras11.2g ASH extras

Statistics Statistics TM_DELTA_TIMETM_DELTA_CPU_TIMETM_DELTA_DB_TIMEDELTA_TIMEDELTA_READ_IO_REQUESTSDELTA_WRITE_IO_REQUESTSDELTA_READ_IO_BYTESDELTA_WRITE_IO_BYTESDELTA_INTERCONNECT_IO_BYTESPGA_ALLOCATEDTEMP_SPACE_ALLOCATE

Page 38: Oracle 10g Performance: chapter 01 ash

#.38Copyright 2006 Kyle Hailey

10.110.1 10.210.2 10.2.0.310.2.0.3 11.111.1 11.211.2

WhenWho

SQL

Waits

Blocker

Statistics

ASH Across VersionsASH Across Versions

ASH instrumentation is exploding across the versions

Page 39: Oracle 10g Performance: chapter 01 ash

#.39Copyright 2006 Kyle Hailey

How Many Active Sessions?How Many Active Sessions?

How much data does ASH Collect ? 1 CPU means max 1 Avg Active Session unless

there is a bottleneck

Big site examples: Oracle 4 way RAC internal apps

10,000 connected, 200 active

One Site 3000 connected, 30 Active

Site 12,000 connected, 100 active

Page 40: Oracle 10g Performance: chapter 01 ash

#.40Copyright 2006 Kyle Hailey

ASH SummaryASH Summary Rich & Multidimensional

Overview of system load Drilldowns into problems

Sql Session Wait event

Details information on problem resolution 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

OEM simplifies mining of ASH data

Page 41: Oracle 10g Performance: chapter 01 ash

#.41

Q1Q1

Copyright 2006 Kyle Hailey

How can you immediately find the top IO consuming SQL How can you immediately find the top IO consuming SQL statement in the last 60 secondsstatement in the last 60 seconds

a. v$active_session_historya. v$active_session_history

b. v$sqlstatsb. v$sqlstats

c. v$sqlc. v$sql

d. v$sqlaread. v$sqlarea

answeranswer

a onlya only

othersothers

b,c,d - only have cumulative values b,c,d - only have cumulative values since database startup since database startup

Page 42: Oracle 10g Performance: chapter 01 ash

#.42

Q2Q2

Copyright 2006 Kyle Hailey

Which view can you query directly to Which view can you query directly to get the specific waits that occurred get the specific waits that occurred 30 minutes ago:30 minutes ago:a. v$active_session_historya. v$active_session_historyb. v$waitclassmetricb. v$waitclassmetricc. v$system_eventc. v$system_eventd. v$session_wait_historyd. v$session_wait_historye. v$waitclassmetric_historye. v$waitclassmetric_history

a onlya onlyb - last 60 seconds onlyb - last 60 seconds onlyc - cumulative info since db startupc - cumulative info since db startupd - last 10 waits onlyd - last 10 waits onlye - only wait groups, not wait events, but has e - only wait groups, not wait events, but has the history for last hourthe history for last hour

Page 43: Oracle 10g Performance: chapter 01 ash

#.43

Q3Q3

Copyright 2006 Kyle Hailey

ASH (v$active_session_history) is a revolutionary data ASH (v$active_session_history) is a revolutionary data source for monitoring and analyzing database source for monitoring and analyzing database performance. The view v$active_session_history is new performance. The view v$active_session_history is new in 10g, but most of the data needed in order to simulate in 10g, but most of the data needed in order to simulate v$active_session_history by hand has been available v$active_session_history by hand has been available since which versionsince which version a. 6a. 6b. 7b. 7c. 8c. 8d. 9d. 9e. 10e. 10

b - since version 7 when wait events b - since version 7 when wait events were introduced along with the view were introduced along with the view v$session_wait v$session_wait

which is the foundation for ASHwhich is the foundation for ASH