#.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 Copyright 2006 Kyle Hailey 10 Machines with 4 processors and 1 database each 1 DBA OEM $5,000 per pack unlimited users $2,500 per pack with minimum named users
#.3 Copyright 2006 Kyle Hailey Simulating ASH ASH is new in 10g ASH data exist since V7 Need Diagnostic Pack License Collect it yourself SASH – Simulated ASH Graphical Monitor Consumes < 1% CPU for 10 active sessions (a lot)
#.4 4 Simulating ASH Performance Package License? $5000/pack/CPU ? Not on 10g ? Do it yourself V$SESSION 10g most of ASH Before 10g, join v$session and v$session_wait Sample every second Store in a table Free PL/SQL package v$active_session_history v$session SESSION_ID SID SESSION_SERIAL# SERIAL# USER_ID USER# SQL_OPCODE COMMAND PROGRAM PROGRAM SESSION_TYPE TYPE SQL_ID SQL_ID SQL_CHILD_NUMBER SQL_CHILD_NUMBER MODULE MODULE ACTION ACTION CURRENT_OBJ# ROW_WAIT_OBJ# CURRENT_FILE# ROW_WAIT_FILE# CURRENT_BLOCK# ROW_WAIT_BLOCK# CLIENT_ID CLIENT_IDENTIFIER BLOCKING_SESSION BLOCKING_SESSION BLOCKING_SESSION_STATUS BLOCKING_SESSION_STATUS SEQ# SEQ# EVENT# EVENT# EVENT EVENT P1TEXT P1TEXT P1 P1 P2TEXT P2TEXT P2 P2 P3TEXT P3TEXT P3 P3 WAIT_CLASS_ID WAIT_CLASS_ID WAIT_CLASS WAIT_CLASS WAIT_TIME WAIT_TIME
#.5 5 ASH extra fields v$session missing V$session extras FORCE_MATCHING_SIGNATURE v$sql.sql_id = sql_id QC_SESSION_ID QCSID v$px_session.sid=sid, serial# QC_INSTANCE_ID QCINST_ID v$px_session.sid=sid, serial# SQL_PLAN_HASH_VALUE PLAN_HASH_VALUE v$sqlstats.sql_id v$sqlstats.sql_id = sql_id (PLAN_HASH_VALUE = x$ksuse.KSUSESPH) XID v$transaction.ADDR = taddr FIXED_TABLE_SEQUENCE - find sql executions ROW_WAIT_ROW# LAST_CALL_ET - how long in current state
#.6 Simulating – Key Ideas session_state = decode(WAIT_TIME, 0,'WAITING', 'ON CPU') v$session where status='ACTIVE' and ON CPU : wait_time != 0 or Waiting : wait_class != 'Idle‘ select sysdate sample_time, decode(s.WAIT_TIME, 0,'WAITING','ON CPU') "SESSION_STATE" decode(s.WAIT_TIME, 0,'WAITING','ON CPU') "SESSION_STATE" /* plus other fields */ /* plus other fields */ from v$session s from v$session s where sid != ( select sid from v$mystat where rownum < 2 ) where sid != ( select sid from v$mystat where rownum < 2 ) and ( ( s.status='ACTIVE' and wait_time != 0 ) and ( ( s.status='ACTIVE' and wait_time != 0 ) or s.wait_class!='Idle' ) ; or s.wait_class!='Idle' ) ; 9i – join v$session and v$session_wait
#.7 Copyright 2006 Kyle Hailey Sampling Method 7,8,9i, 10g select s.username, s.sid, s.serial#, s.sql_hash_value, decode(w.wait_time, 0, w.event, 'ON CPU'), w.p1 p1, w.p2 p2, w.p3 p3 select s.username, s.sid, s.serial#, s.sql_hash_value, decode(w.wait_time, 0, w.event, 'ON CPU'), w.p1, w.p2, w.p3 select s.username, s.sid, s.serial#, s.sql_hash_value, decode(w.wait_time, 0, w.event, 'ON CPU'), w.p1, w.p2, w.p3 from v$session s, v$session_wait w where w.sid=s.sid and s.status='ACTIVE' and s.type='USER' / from v$session s, v$session_wait w where w.sid=s.sid and s.status='ACTIVE' and s.type='USER' /
#.8 Copyright 2006 Kyle Hailey Sampling v$session10g select username, sid, serial#, sql_hash_value, decode(wait_time, 0, event, 'ON CPU'), p1,p2, p3 from v$session where status='ACTIVE' and name not in ( select event from v$event_name where wait_class='Idle' ) / select username, sid, serial#, sql_hash_value, decode(wait_time, 0, event, 'ON CPU'), p1,p2, p3 from v$session where status='ACTIVE' and name not in ( select event from v$event_name where wait_class='Idle' ) /
#.9 Copyright 2006 Kyle Hailey Example of Sampled Data From the above query we get output like USERNAME SID SERIAL HASH_VALUE EVENT P1 P2 P SYS PL/SQL lock timer SYS ON CPU STARGUS direct path write (CJQ0) rdbms ipc message Session SQL Wait USERNAME SID SERIAL HASH_VALUE EVENT P1 P2 P SYS PL/SQL lock timer SYS ON CPU STARGUS direct path write (CJQ0) rdbms ipc message USERNAME SID SERIAL HASH_VALUE EVENT P1 P2 P SYS PL/SQL lock timer SYS ON CPU STARGUS direct path write (CJQ0) rdbms ipc message
#.10 Copyright 2006 Kyle Hailey Example of Sampled Data From the above query we get output like USERNAME SID SERIAL HASH_VALUE EVENT P1 P2 P SYS buffer busy wait Wait file block Type USERNAME SID SERIAL HASH_VALUE EVENT P1 P2 P SYS buffer busy wait USERNAME SID SERIAL HASH_VALUE EVENT P1 P2 P SYS buffer busy wait SQL Session
#.11 Copyright 2006 Kyle Hailey V1 - SASH - Simulating ASH Install ashpack.sh (UNIX only) Automatically collects Every 3 secs v$session_wait + v$session 10g just uses v$session – faster Every Hour collects Top 20 SQL text Top 20 SQL explain plans Top 20 SQL stats Top 20 Object names (not enabled) Keeps 7 days, purges rest Needs Partitioning Option
#.12 Copyright 2006 Kyle Hailey SASH - Architecture # REPOSITORY REPO_SCHEMA=sash REPO_PW=sash REPO_SID=cdb REPO_HOST=cont01.perfvision.com REPO_PORT=1521 #TARGET TARG_SCHEMA=sys TARG_PW="sys as sysdba" TARG_HOST=`hostname` TARG_SID=$ORACLE_SID TARG_HOME=$ORACLE_HOME Define once And leave in script ashpack.sh
#.13 Copyright 2006 Kyle Hailey SASH - Architecturerepository target target target target Targets run jobs to insert data over db link ashpack.sh oracle ashpack.sh
#.14 Copyright 2006 Kyle Hailey SASH - Architecturerepository ASH data partitioned by DBID of Target Day of Week Makes purge fast Make queries fast
#.15 V2 SASH Installs on any platform (no longer UNIX only) Installs on Standard Edition Uses “poor mans partitioning” “v$active_session_history” is a union on SASH1-SASH7 Purging done by truncating the oldest SASH1-7 table Copyright 2006 Kyle Hailey
#.16 V2 SASH Repository repo_0_user.sql optional example of create the “sash” user on repository (as SYS or SYSTEM) repo_1_tables.sql install schema on repository database (run as SASH user) Monitored Database targ_1_pkg.sql install package database to be monitored (run as or sys) targ_2_jobs.sql start up collection in a job Optionally repo_2_pkg.sql Install purge procedure (on repository) repo_3_jobs.sql Run purge in job (on repository) Copyright 2006 Kyle Hailey
#.17 Copyright 2006 Kyle Hailey SASH - Architecturerepository target target target target Targets run jobs to insert data over db link repo_0_user.sql repo_1_tables.sql repo_2_pkg.sql repo_3_jobs.sql targ_1_pkg.sql targ_2_jobs.sql targ_1_pkg.sql targ_2_jobs.sql targ_1_pkg.sql targ_2_jobs.sql targ_1_pkg.sql targ_2_jobs.sql Oracle as SASH user Everything else as SYS or SYSTEM
#.18 Notes on Data Mining Now data extraction: S-ASH creates a view v$active_session_history scripts are thus compatible with 10g ASH scripts repo_4_waitgroups.sql To be fully compatible with 10g ASH scripts set up a simulated wait groups (don’t exist before 10g) repo_5_curdb.sql change the DBID in v$active_session_history view S-ASH can collect data from multiple databases To keep scripts compatible with 10g ASH scripts I define a filter on DBID in the view v$active_session_history Copyright 2006 Kyle Hailey HOST SFLKHAI01TORKHAI01ROMKHAI01 Enter value for host: SFLKHAI01 1 row deleted. 1 row created.
#.19 Copyright 2006 Kyle Hailey S-ASH – All HOST ASL GRAPH # of cpus bsn control cont bsn tsukuba limerock.13 2 bsn devnode.02 HOST ASL GRAPH # of cpus bsn control cont bsn tsukuba limerock.13 2 bsn devnode.02 1
#.20 Copyright 2006 Kyle Hailey Simulating ASH – All DB HOST EVENT ASL CNT bsn02 local write wait.00 1 buffer busy waits.01 5 db file sequential read.01 6 log file sync write complete waits free buffer waits CPU Sum.44 bsn08 buffer busy waits log buffer space log file sync enqueue db file scattered read rdbms ipc reply local write wait db file sequential read direct path write direct path read CPU Sum HOST EVENT ASL CNT bsn02 local write wait.00 1 buffer busy waits.01 5 db file sequential read.01 6 log file sync write complete waits free buffer waits CPU Sum.44 bsn08 buffer busy waits log buffer space log file sync enqueue db file scattered read rdbms ipc reply local write wait db file sequential read direct path write direct path read CPU Sum 1.38
#.21 Copyright 2006 Kyle Hailey SASH – DB Detailed Analysis Begin Time : :04:48 Analysis End Time : :19:45 Start time, mins ago: 15 Request Duration : 15 Collections : 528 Data Values : 3327 Elapsed Time: 15 mins WAIT_EVENT CNT % Active Ave_Act_Sess latch free log buffer space buffer busy waits db file scattered read library cache pin log file sync ON CPU enqueue db file sequential read sum Analysis Begin Time : :04:48 Analysis End Time : :19:45 Start time, mins ago: 15 Request Duration : 15 Collections : 528 Data Values : 3327 Elapsed Time: 15 mins WAIT_EVENT CNT % Active Ave_Act_Sess latch free log buffer space buffer busy waits db file scattered read library cache pin log file sync ON CPU enqueue db file sequential read sum 6.3
#.22 Copyright 2006 Kyle Hailey SASH – AAS over TM NPTS AVEACT GRAPH CPU WAITS AUG 13:00: AUG 14:00: AUG 15:00: AUG 16:00: AUG 17:00: AUG 18:00: AUG 19:00: AUG 20:00: AUG 21:00: AUG 22:00: AUG 23:00: AUG 00:00: AUG 01:00: AUG 02:00: AUG 03:00: AUG 04:00: AUG 05:00: AUG 06:00: AUG 07:00: AUG 08:00: AUG 09:00: TM NPTS AVEACT GRAPH CPU WAITS AUG 13:00: AUG 14:00: AUG 15:00: AUG 16:00: AUG 17:00: AUG 18:00: AUG 19:00: AUG 20:00: AUG 21:00: AUG 22:00: AUG 23:00: AUG 00:00: AUG 01:00: AUG 02:00: AUG 03:00: AUG 04:00: AUG 05:00: AUG 06:00: AUG 07:00: AUG 08:00: AUG 09:00:
#.23 Copyright 2006 Kyle Hailey SASH – AAS over time with TO_CHAR(STA AAS AAS1 FIRST AAS2 SECOND GRAPH :00: db file sequent.10 CPU :00: direct path wri.49 log file sync :00: direct path wri 1.93 log file sync :00: direct path wri.57 log file sync :00: log file sync.32 CPU :00: CPU.45 log file sync :00: log file sync.39 CPU :00: log file sync.27 CPU :00: log file sync.31 CPU :00: log file sync.41 CPU :00: log file sync.27 CPU :00: log file sync.27 CPU :00: log file sync.31 CPU :00: direct path wri.52 log file sync :00: direct path wri 1.58 log file sync :00: CPU.27 log file sync :00: CPU.83 enqueue TO_CHAR(STA AAS AAS1 FIRST AAS2 SECOND GRAPH :00: db file sequent.10 CPU :00: direct path wri.49 log file sync :00: direct path wri 1.93 log file sync :00: direct path wri.57 log file sync :00: log file sync.32 CPU :00: CPU.45 log file sync :00: log file sync.39 CPU :00: log file sync.27 CPU :00: log file sync.31 CPU :00: log file sync.41 CPU :00: log file sync.27 CPU :00: log file sync.27 CPU :00: log file sync.31 CPU :00: direct path wri.52 log file sync :00: direct path wri 1.58 log file sync :00: CPU.27 log file sync :00: CPU.83 enqueue
#.24 Copyright 2006 Kyle Hailey Aveact.sql
#.25 Copyright 2006 Kyle Hailey “-” = WAIT “+” = CPU which waits ? -> aveactn.sql
#.26 Aveactn.sql Copyright 2006 Kyle Hailey
#.27 Copyright 2006 Kyle Hailey SASH – SQL START_TIME COUNT(*) SQL_ID FIXED_TABLE_SEQUENCE TOPN JUN-01 02: JUN-01 02: JUN-01 02: JUN-01 02: JUN-01 02: JUN-01 02: JUN-01 02: START_TIME COUNT(*) SQL_ID FIXED_TABLE_SEQUENCE TOPN JUN-01 02: JUN-01 02: JUN-01 02: JUN-01 02: JUN-01 02: JUN-01 02: JUN-01 02: Using v$session fixed_table_sequence and sql_hash
#.28 Copyright 2006 Kyle Hailey ASHMON a free “OEM-lite” Windows application Monitors Oracle 10g or 11 Show “Top Activity” page from OEM Note: Can be used on any version of Oracle with performance repository available on
#.29 ASHMON 06/05/08
#.30 Swingbench Simulated DB activity
#.31 ASHMON Aggregates Drilldowns Time Slicing Guidance 31 1/15/2016
#.32 Copyright 2006 Kyle Hailey CPU > Max CPU
#.33 Copyright 2006 Kyle Hailey Radical Change in Profile
#.34 $5K/CPU Oracle Database = Copyright 2006 Kyle Hailey OEMASHMON DB Optimizer HSQL – local DB licensedsys/systemV$active_session_history FreesashV$active_session_history Free $1500 unlimited
#.35 Copyright 2006 Kyle Hailey Quest – Performance Analyzer Good interface SGA direct access only Good – fast, low impact Bad – difficult to install and administer
#.36 Copyright 2006 Kyle Hailey Quest
#.37 Copyright 2006 Kyle Hailey Quest
#.38 Copyright 2006 Kyle Hailey Symantec’s I3 End to End monitoring Right Data Complicated to Install and administer
#.39 Copyright 2006 Kyle Hailey Symantec
#.40 Copyright 2006 Kyle Hailey Symantec I3
#.41 Copyright 2006 Kyle Hailey Symantec I3
#.42 Copyright 2006 Kyle Hailey Lab 128 Easy Fast Cheap Great data analysis Collects right information Complicated interface - “Geeks tool” No Analysis
#.43 Copyright 2006 Kyle Hailey Confio’s Ignite
#.44 DB Optimizer Copyright 2006 Kyle Hailey
#.45 Copyright 2006 Kyle Hailey Lab128
#.46 Copyright 2006 Kyle Hailey Summary Tools Tools Quest Performance Analyst Confio’s Ignite Symantec’s I3 Lab128 DB Optimizer Free but no graphics SASH Your custom queries Simulated ASH
#.47 OEMDB Optimizer Lab 128SASH performance$100,000$1500$500free SQL Tuning$100,000includedN/A Both$200,000$1500N/A Copyright 2006 Kyle Hailey 10 Machines with 4 processors and 1 database each 1 DBA OEM $5,000 per pack unlimited users $2,500 per pack with minimum named users