#.1 ASH – Active Session History Feel the Power Kyle Hailey

Slides:



Advertisements
Similar presentations
1 Chapter 16 Tuning RMAN. 2 Background One of the hardest chapters to develop material for Tuning RMAN can sometimes be difficult Authors tried to capture.
Advertisements

9 Copyright © 2006, Oracle. All rights reserved. Automatic Performance Management.
Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
The Architecture of Oracle
1 Wait Event Enhancements in Oracle 10g Terry Sutton and Roger Schrag Database Specialists, Inc.
IO Waits Kyle Hailey #.2 Copyright 2006 Kyle Hailey Waits Covered in this Section  db file sequential read  db file scattered.
Enqueue Waits : Locks. #.2 Copyright 2006 Kyle Hailey Locks REDO Lib Cache Buffer Cache IO Locks Network.
4 Copyright © 2005, Oracle. All rights reserved. Managing the Oracle Instance.
Finding the Performance Bottlenecks in Your Application Ian Jones and Roger Schrag Database Specialists, Inc. IOUG-A Live! 1999 Paper.
Royal London Group A group of specialist businesses where the bottom line is always financial sense Oracle Statistics – with a little bit extra on top.
1 Chapter 16 Latch and Mutex Contention. 2 Architecture Overview of Latches Protect Oracle’s SGA Prevent two processes from updating same area of SGA.
Buffer Cache Waits. #.2 Copyright 2006 Kyle Hailey Buffer Cache Waits Waits Disk I/O Buffer Busy Library Cache Enqueue SQL*Net Free Buffer Hot Blocks.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
Overview of Database Administrator (DBA) Tools
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 2 Overview of Database Administrator (DBA) Tools.
Oracle 10.2 for z/OS and z/Linux Performance Update.
The Self-managing Database: Automatic Performance Diagnosis Graham Wood Kyle Hailey Oracle Corporation Session id:
6 Copyright © 2006, Oracle. All rights reserved. Using Automatic Workload Repository.
ASH – Active Session History Feel the Power Kyle Hailey Embarcadero Technologies
Oracle Architecture. Database instance When a database is started the current state of the database is given by the data files, a set of background (BG)
1 Tuning PL/SQL procedures using DBMS_PROFILER 20-August 2009 Tim Gorman Evergreen Database Technologies, Inc. Northern California Oracle.
Average Session Load (ASL) The Golden Metric ? Kyle Hailey
Waits Defined Kyle Hailey #.2 Copyright 2006 Kyle Hailey Top 36 Foreground Waits write complete waits library cache.
ASH – Active Session History Kyle Hailey Embarcadero Technologies
It’s time to do ASH! Tuesday, Februrary 8 th 2005 Gaja Krishna Vaidyanatha Principal, DBPerfMan LLC
© 2009 Convio, Inc. End-to-End Metrics for Troubleshooting and Monitoring Dave Abercrombie Principal Database Architect, Convio NoCOUG Spring Conference.
ASH Masters Kyle Hailey kylehailey.com slideshare.net/khailey 1 8/28/2015 ASH SQL Query Repository.
12 Copyright © 2004, Oracle. All rights reserved. Automatic Management.
To Do  ADDM – add chart showing advice over time  Client id – draw sessions and client bouncing from session to session  Services – show connection.
12 Copyright © 2007, Oracle. All rights reserved. Database Maintenance.
2 Copyright © 2006, Oracle. All rights reserved. Performance Tuning: Overview.
Performance Tuning in Oracle 10g Feel the Power !
#.1 Oracle Wait Interface in Oracle 10g. #.2 Today’s Session  Twelve wait event interface enhancements in Oracle 10g that we really like.  Documentation.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
Part II : Waits Events Kyle Hailey
Performance Diagnostics using STATSPACK data 18-May 2006 Tim Gorman SageLogix, Inc. N. CA Oracle Users Group.
Oracle Tuning Considerations. Agenda Why Tune ? Why Tune ? Ways to Improve Performance Ways to Improve Performance Hardware Hardware Software Software.
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
1 06/05/08 Statspack Kyle Hailey
8 Copyright © 2005, Oracle. All rights reserved. Managing Data.
ASH – Active Session History Feel the Power Kyle Hailey
Oracle 10g Advanced Performance Tuning Kyle Hailey Delphix - wait events docs – tools S-ASH.
Average Active Sessions (AAS) The Golden Metric ? Kyle Hailey
Process Architecture Process Architecture - A portion of a program that can run independently of and concurrently with other portions of the program. Some.
#.6 Sampling Kyle Hailey
Troubleshooting 11i issues Adam Janbolat
10G - New Manageability Features Presented by Lenka Vanek
#.1 SASH – Simulated ASH and other tools. #.2 OEMDB Optimizer Lab 128SASH performance$100,000$1500$500free SQL Tuning$100,000includedN/A Both$200,000$1500N/A.
Tracing Individual Users in Connection-pooled Environments with Oracle 10g Terry Sutton Database Specialists, Inc.
3 Copyright © 2006, Oracle. All rights reserved. Statistics and Wait Events.
#.1 Average Active Sessions (AAS) The Golden Metric ? Kyle Hailey
7 Copyright © Oracle Corporation, All rights reserved. Instance and Media Recovery Structures.
OEM 10g Performance and Tuning. #.2 Copyright 2006 Kyle Hailey Performance SQL Diagnostics SQLTuning Performance Session DB HOME.
SQL*Net & Other Waits. #.2 Copyright 2006 Kyle Hailey SQL*Net Waits Session Shadow Log Buffer Buffer Cache Log Buffer Buffer Cache SGA Library Cache Host.
1 3/21/2016 Average Active Sessions (AAS) The Golden Metric ? Kyle Hailey perfvision.com.
3 Copyright © 2004, Oracle. All rights reserved. Database Architecture Comparison.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1.
Same Plan Different Performance Mauro Pagano. Consultant/Developer/Analyst Oracle  Enkitec  Accenture DBPerf and SQL Tuning Training Tools (SQLT, SQLd360,
SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS.
Oracle Database Architectural Components
1 Copyright © 2005, Oracle. All rights reserved. Oracle Database Administration: Overview.
1 PVSS Oracle scalability Target = changes per second (tested with 160k) changes per client 5 nodes RAC NAS 3040, each with one.
Chapter 21 SGA Architecture and Wait Event Summarized & Presented by Yeon JongHeum IDS Lab., Seoul National University.
Interpreting Wait Events To Boost System Performance
ASH – Active Session History Feel the Power
Wait Event Enhancements in Oracle 10g
Presentation transcript:

#.1 ASH – Active Session History Feel the Power Kyle Hailey

#.2 Copyright 2006 Kyle Hailey 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

#.3 Copyright 2006 Kyle Hailey Revolution 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)

#.4 Copyright 2006 Kyle Hailey Sampling New 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

#.5 Copyright 2006 Kyle Hailey Identify Players before ASH  Sessions v$sesstat, v$session_event  # sessions x (# wait events + statistics)  Example (150 x ( ) = 150,000 )  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 ! Also files v$filestat

#.6 Copyright 2006 Kyle Hailey ASH 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

#.7 Copyright 2006 Kyle Hailey IDLE  Example : SQL*Net Message from Client  10g  9i or below – just have to keep track  Statspack STATS$IDLE_EVENT select name from v$event_name where wait_class='Idle'; 58 Rows select * from v$session where wait_class != 'Idle' and status='ACTIVE';

#.8 Copyright 2006 Kyle Hailey CPU  ASH: SESSION_STATE = “ON CPU” 10g: v$session 9i: v$session_wait w.wait_time != 0 /* on CPU */ and s.status='ACTIVE' /* ACTIVE */ Identifying CPU via v$session_wait is a huge break through select * from v$session where wait_time > 0 and status='ACTIVE';

#.9 Copyright 2006 Kyle Hailey IO  ASH: SESSION_STATE=‘WAITING’ and …  10g: WAIT_CLASS=‘User I/O’  9i:  Look at 10g for ideas  db file sequential read  db file scattered read  db file parallel read  direct path read select * from v$session where wait_class = 'User I/O‘ and wait_time <= 0; select * from v$session where wait_class = 'User I/O‘ and wait_time <= 0;

#.10 Copyright 2006 Kyle Hailey WAITING  ASH: SESSION_STATE=‘WAITING’  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 select * from v$session where wait_time <= 0 and status='ACTIVE‘ and wait_class != 'Idle';

#.11 Copyright 2006 Kyle Hailey ASH Fields ASH Fields SQL> 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

#.12 Copyright 2006 Kyle Hailey v$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

#.13 Copyright 2006 Kyle Hailey Primary Fields of ASH SESSION_ID EVENT SQL_ID SAMPLE_TIME Time Session SQL Wait SESSION_STATE State Activity : Who, What, When, How Who What When How

#.14 Copyright 2006 Kyle Hailey Amazing 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

#.15 Multi-dimensional 06/05/ F1qcyh20550cffj6gjgsshtxyx0cjsxw5ndqdbc8t8as9usk11qwdr1rkrznhh95b10dkqv3kr8xa538zhkf4jdyff4298wmz1kxjs1m CPU Enq: TX – row lock contention SQL*Net break/reset to client db file scattered read db file sequential read IO Application SQL Sessions WaitsStatistics Service Scott System User Program Sys Sqlplus Toad GL OE Package Procedure Plan Child #

#.16 Copyright 2006 Kyle Hailey Groupings – Top Consumer SESSION_ID SESSION_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_ID QC_SESSION_ID (Query Coordinator) QC_INSTANCE_ID (RAC) EVENT + P1, P2, P3

#.17 Copyright 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 Session Top CPU consuming Session in last 5 minutes Who is the rogue session ?

#.18 Copyright 2006 Kyle Hailey Results Top CPU Session SESSION_ID COUNT(*) SESSION_ID COUNT(*)

#.19 Copyright 2006 Kyle Hailey CPU with Bars SESSION_ID COUNT(*) % Bar |**********| |** | |* | | | | | | | | | SESSION_ID COUNT(*) % Bar |**********| |** | |* | | | | | | | | | Bar shows 10% increments

#.20 Copyright 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

#.21 Copyright 2006 Kyle Hailey SESSION_ID COUNT(*) SESSION_ID COUNT(*) Top Waiting Session Results

#.22 Copyright 2006 Kyle Hailey Top SQL from ASH 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

#.23 Copyright 2006 Kyle Hailey Top SQL from ASH Results SQL_ID CPU WAITING IO TOTAL c1xvq9ufwcjc wjw6rz5uvbp dm8hr9qd jp5gasmrah cv8xnv81kf p9bzu19v965k zu8pxnun66bu db2jr13nup72v ks5gnj38hghv SQL_ID CPU WAITING IO TOTAL c1xvq9ufwcjc wjw6rz5uvbp dm8hr9qd jp5gasmrah cv8xnv81kf p9bzu19v965k zu8pxnun66bu db2jr13nup72v ks5gnj38hghv

#.24 Copyright 2006 Kyle Hailey Top 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 en where en.event# = ash.event# group by session_id,user_id,session_serial#,program order 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 en where en.event# = ash.event# group by session_id,user_id,session_serial#,program order 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 en where en.event# = ash.event# group by session_id,user_id,session_serial#,program order by sum(decode(session_state,'ON CPU',1,1))

#.25 Copyright 2006 Kyle Hailey Top Session Results SESSION_ID SERIAL# USER_ID PROGRAM CPU WAITING IO sqlplus (LGWR) (CKPT) (DBW0) (PMON) Executor.exe Executor.exe Executor.exe Executor.exe SESSION_ID SERIAL# USER_ID PROGRAM CPU WAITING IO sqlplus (LGWR) (CKPT) (DBW0) (PMON) Executor.exe Executor.exe Executor.exe Executor.exe

#.26 Copyright 2006 Kyle Hailey Top Session w/ Username 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 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

#.27 Copyright 2006 Kyle Hailey Top Session Finding a Rogue User STATUS SESSION_ID NAME PROGRAM CPU WAITING IO CONNECTED 247 CPU_Monger ChMgr304.exe CONNECTED 277 SYS (LGWR) CONNECTED 278 SYS (DBW0) CONNECTED 276 SYS (CKPT) CONNECTED 280 SYS (PMON) DISCONNECTED 255 SYSTEM Executor.exe DISCONNECTED 257 SYSTEM Executor.exe DISCONNECTED 255 SYSTEM Executor.exe DISCONNECTED 257 SYSTEM Executor.exe STATUS SESSION_ID NAME PROGRAM CPU WAITING IO CONNECTED 247 CPU_Monger ChMgr304.exe CONNECTED 277 SYS (LGWR) CONNECTED 278 SYS (DBW0) CONNECTED 276 SYS (CKPT) CONNECTED 280 SYS (PMON) DISCONNECTED 255 SYSTEM Executor.exe DISCONNECTED 257 SYSTEM Executor.exe DISCONNECTED 255 SYSTEM Executor.exe DISCONNECTED 257 SYSTEM Executor.exe

#.28 Copyright 2006 Kyle Hailey Many 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

#.29 Copyright 2006 Kyle Hailey Mining Data is Non Trivial  Many Dimensions to consider  Constantly Varying time frames  Luckily 10g automates all of this functionality.  collects all of the data  analyses all the wait events  reports on bottlenecks  supplies solutions  Graphics add tremendous ease and power

#.30 Copyright 2006 Kyle Hailey OEM Perf Page

#.31 Copyright 2006 Kyle Hailey ASH Sampling Cheap Three ways to sample – comparison of impact: 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

#.32 Copyright 2006 Kyle Hailey 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)

#.33 Copyright 2006 Kyle Hailey ASH Sizing …  Avg row around 150bytes  3600 secs in an hour  ~ ½ Meg per Active Session per hour  That’s generally over 2 hours of ASH

#.34 Copyright 2006 Kyle Hailey How 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, AWR M000 – MMON background slave, runs snapshots MMNL - MMON lite, flushes ASH to disk

#.35 Copyright 2006 Kyle Hailey Select reads backwards - -No latching - -Index on time - -No read consistency Insert point ASH buffer Insert one direction Touch up wait times

#.36 Copyright 2006 Kyle Hailey Family 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)

#.37 Copyright 2006 Kyle Hailey Wait Time vs Time Waited  SESSION_STATE  Waiting, on CPU  Based on WAIT_TIME  WAIT_TIME (v$session, v$session_wait, v$ash)  0 => waiting  >0 => CPU (value is time of last wait)  TIME_WAITED  Actual time waited for event  0 until wait finishes  Fix up values (no one else can do this)

#.38 Copyright 2006 Kyle Hailey Oradebug  Dump to trace file SQL> oradebug dump ash 5 SQL> Alter session set events ‘immediate tracename ashdump level 5’; level 5 = # of minutes loader file rdbms/demo/ashldr.ctl SQL> oradebug dump ashdump 5 SQL> Alter session set events ‘immediate trace name ashdump level 5’;

#.39 Copyright 2006 Kyle HaileyINIT.ORA statistics_level = Typical (default) PARAMETER SESSION_VALUE INSTANCE_VAL _ash_sampling_interval milliseconds _ash_size 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 write 1 in 10 points _ash_sample_all FALSE FALSE Sample including idle waits

# ASH Extras  Blocking Session !  BLOCKING_SESSION  BLOCKING_SESSION_STATUS  BLOCKING_SESSION_SERIAL# 40 12/17/2015 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   Parameter Names   P1TEXT, P2TEXT, P3TEXT   Wait Grouping   WAIT_CLASS   WAIT_CLASS_ID   XID   FORCE_MATCHING_SIGNATURE   Cursor sharing

# ASH Extras PLSQL_ENTRY_OBJECT_ID PLSQL_ENTRY_SUBPROGRAM_ID PLSQL_OBJECT_ID PLSQL_SUBPROGRAM_ID 41 12/17/2015 ALL_PROCEDURES where object_id = plsql_object_id where object_id = plsql_object_id and subprogram_id = plsql_subprogram_id

# /17/2015 PLSQL Tracking  Package/Procedure/SQL tracking calling_code SQL_ID COUNT(*) ORDERENTRY.NEWORDER 0uuqgjq7k12nf 258 ORDERENTRY.NEWCUSTOMER 0bzhqhhj9mpaa 262 ORDERENTRY.BROWSEANDUPDATEORDERS 41zu158rqf4kf 301 ORDERENTRY.NEWORDER 0yas01u2p9ch4 569 PARSE_SAME 3vjxpmhhzngu4 874 ORDERENTRY.BROWSEANDUPDATEORDERS 05s4vdwsf 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

#.43 Copyright 2006 Kyle Hailey 11.1g ASH extras SQL 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 ETC Operation bit vector – non timed ops SQL Row Source REMOTE_INSTANCE# Which instance requested block? TOP_LEVEL_SQL_ID TOP_LEVEL_SQL_OPCODE Recursive SQL

#.44 Copyright 2006 Kyle Hailey 11.2g ASH extras Statistics TM_DELTA_TIME TM_DELTA_CPU_TIME TM_DELTA_DB_TIME DELTA_TIME DELTA_READ_IO_REQUESTS DELTA_WRITE_IO_REQUESTS DELTA_READ_IO_BYTES DELTA_WRITE_IO_BYTES DELTA_INTERCONNECT_IO_BYTES PGA_ALLOCATED TEMP_SPACE_ALLOCATE

#.45 Copyright 2006 Kyle Hailey When Who SQL Waits Blocker Statistics ASH Across Versions ASH instrumentation is exploding across the versions

#.46 Copyright 2006 Kyle Hailey 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

#.47 Copyright 2006 Kyle Hailey ASH 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

#.48 Q1 Copyright 2006 Kyle Hailey How can you immediately find the top IO consuming SQL statement in the last 60 seconds a. v$active_session_history b. v$sqlstats c. v$sql d. v$sqlarea answer a only others b,c,d - only have cumulative values since database startup

#.49 Q2 Copyright 2006 Kyle Hailey Which view can you query directly to get the specific waits that occurred 30 minutes ago: a. v$active_session_history b. v$waitclassmetric c. v$system_event d. v$session_wait_history e. v$waitclassmetric_history a only b - last 60 seconds only c - cumulative info since db startup d - last 10 waits only e - only wait groups, not wait events, but has the history for last hour

#.50 Q3 Copyright 2006 Kyle Hailey ASH (v$active_session_history) is a revolutionary data source for monitoring and analyzing database performance. The view v$active_session_history is new in 10g, but most of the data needed in order to simulate v$active_session_history by hand has been available since which version a. 6 b. 7 c. 8 d. 9 e. 10 b - since version 7 when wait events were introduced along with the view v$session_wait which is the foundation for ASH