#.1 sash – simulated ash and other tools. #.2 oemdb optimizer lab 128sash...
DESCRIPTION
#.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)TRANSCRIPT
#.1
SASH – Simulated ASHand other tools
#.2
OEM DB Optimizer
Lab 128 SASH
performance $100,000 $1500 $500 free
SQL Tuning $100,000 included N/A N/A
Both $200,000 $1500 N/A N/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
#.3Copyright 2006 Kyle Hailey
Simulating ASH
ASH is new in 10g ASH data exist since V7 Need Diagnostic Pack License Collect it yourself
SASH – Simulated ASHhttp://perfvision.com/sash.php
Graphical Monitorhttp://perfvision.com/ashmon.php
Consumes < 1% CPU for 10 active sessions (a lot)
#.44
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_historyv$active_session_history v$sessionv$sessionSESSION_ID SID SESSION_ID SID SESSION_SERIAL# SERIAL# SESSION_SERIAL# SERIAL# USER_ID USER# USER_ID USER# SQL_OPCODE COMMAND SQL_OPCODE COMMAND PROGRAM PROGRAM PROGRAM PROGRAM SESSION_TYPE TYPE SESSION_TYPE TYPE SQL_ID SQL_ID SQL_ID SQL_ID SQL_CHILD_NUMBER SQL_CHILD_NUMBER SQL_CHILD_NUMBER SQL_CHILD_NUMBER MODULE MODULE MODULE MODULE ACTION ACTION ACTION ACTION CURRENT_OBJ# ROW_WAIT_OBJ# CURRENT_OBJ# ROW_WAIT_OBJ# CURRENT_FILE# ROW_WAIT_FILE# CURRENT_FILE# ROW_WAIT_FILE# CURRENT_BLOCK# ROW_WAIT_BLOCK# CURRENT_BLOCK# ROW_WAIT_BLOCK# CLIENT_ID CLIENT_IDENTIFIERCLIENT_ID CLIENT_IDENTIFIER BLOCKING_SESSION BLOCKING_SESSION BLOCKING_SESSION BLOCKING_SESSION BLOCKING_SESSION_STATUS BLOCKING_SESSION_STATUS BLOCKING_SESSION_STATUS BLOCKING_SESSION_STATUS SEQ# SEQ# SEQ# SEQ# EVENT# EVENT# EVENT# EVENT# EVENT EVENT EVENT EVENT P1TEXT P1TEXT P1TEXT P1TEXT P1 P1 P1 P1 P2TEXT P2TEXT P2TEXT P2TEXT P2 P2 P2 P2 P3TEXT P3TEXT P3TEXT P3TEXT P3 P3 P3 P3 WAIT_CLASS_ID WAIT_CLASS_ID WAIT_CLASS_ID WAIT_CLASS_ID WAIT_CLASS WAIT_CLASS WAIT_CLASS WAIT_CLASS WAIT_TIME WAIT_TIME WAIT_TIME WAIT_TIME
#.55
ASH extra fields
v$session missing
V$session extras
FORCE_MATCHING_SIGNATURE FORCE_MATCHING_SIGNATURE v$sql.sql_id = sql_idQC_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 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,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 sfrom 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_wait9i – join v$session and v$session_wait
#.7Copyright 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
from v$session s, v$session_wait wwhere w.sid=s.sid and s.status='ACTIVE' and s.type='USER'/
#.8Copyright 2006 Kyle Hailey
Sampling v$session10g
select username, sid, serial#, sql_hash_value, decode(wait_time, 0, event, 'ON CPU'), p1,p2, p3from v$session where status='ACTIVE' and name not in ( select event from v$event_name where wait_class='Idle' ) /
#.9Copyright 2006 Kyle Hailey
Example of Sampled Data
From the above query we get output like
USERNAME SID SERIAL HASH_VALUE EVENT P1 P2 P3-------- --- ------ ---------- ----------------- -------- ------- ---SYS 64 8717 4116021597 PL/SQL lock timer 300 0 0SYS 58 19467 961168820 ON CPU 16508152 1 0STARGUS 71 6251 1311875676 direct path write 201 2155902 127(CJQ0) 9 1 0 rdbms ipc message 500 0 0
Session Session SQL SQL Wait Wait
USERNAME SID SERIAL HASH_VALUE EVENT P1 P2 P3-------- --- ------ ---------- ----------------- -------- ------- ---SYS 64 8717 4116021597 PL/SQL lock timer 300 0 0SYS 58 19467 961168820 ON CPU 16508152 1 0STARGUS 71 6251 1311875676 direct path write 201 2155902 127(CJQ0) 9 1 0 rdbms ipc message 500 0 0
#.10Copyright 2006 Kyle Hailey
Example of Sampled Data
From the above query we get output like
USERNAME SID SERIAL HASH_VALUE EVENT P1 P2 P3-------- --- ------ ---------- ----------------- -------- ------- ---SYS 64 8717 4116021597 buffer busy wait 4 2465 220
Wait Wait
filefileblockblock TypeType
USERNAME SID SERIAL HASH_VALUE EVENT P1 P2 P3
-------- --- ------ ---------- ----------------- -------- ------- ---
SYS 64 8717 4116021597 buffer busy wait 4 2465 220
SQL SQL Session Session
#.11Copyright 2006 Kyle Hailey
V1 - SASH - Simulating ASH
http://perfvision.com/ash.php 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 Needs Partitioning OptionOption
#.12Copyright 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
#.13Copyright 2006 Kyle Hailey
SASH - Architecture
repositoryrepository
targettarget
targettarget
targettarget
targettarget
Targets run jobs to insert data over db linkTargets run jobs to insert data over db link
ashpack.sh
oracleoracle
oracle oracle
oracle
ashpack.sh
ashpack.sh
ashpack.sh
#.14Copyright 2006 Kyle Hailey
SASH - Architecture
repositoryrepository
ASH data partitioned byASH data partitioned by
DBID of TargetDBID of Target
Day of WeekDay of Week
Makes purge fastMakes purge fast
Make queries fastMake queries fast
#.15
V2 SASH
http://ashmasters.com/ash-simulation/ 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-SASH7Purging done by truncating the oldest SASH1-7 table
Copyright 2006 Kyle Hailey
#.16
V2 SASHRepository 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
#.17Copyright 2006 Kyle Hailey
SASH - Architecture
repositoryrepository
targettarget
targettarget
targettarget
targettarget
Targets run jobs to insert data over db linkTargets 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
Oracle
Oracle
Oracle
Oracle
as SASH userEverything else as SYS or SYSTEM
#.18
Notes on Data MiningNow 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
SQL> @repo_5_curdbSQL> @repo_5_curdb
HOSTHOST------------------------------------------------------------SFLKHAI01SFLKHAI01TORKHAI01TORKHAI01ROMKHAI01ROMKHAI01
Enter value for host: SFLKHAI01Enter value for host: SFLKHAI01
1 row deleted.1 row deleted.1 row created.1 row created.
#.19Copyright 2006 Kyle Hailey
S-ASH – All DBs
@actallsum HOST ASL GRAPH --------------- ---------- ----------------------- # of cpus ----1----2----3----4--- bsn08 1.83 +++------2- control1 1.82 ++-------2- cont01 1.28 +----- 2 bsn02 .68 ++-- 4 tsukuba10 .53 -- 2 limerock .13 2 bsn03 .06 4 devnode .02 1
#.20Copyright 2006 Kyle Hailey
Simulating ASH – All DB Details@actallHOST EVENT ASL CNT ---------- ----------------------------------- ------- ---------- bsn02 local write wait .00 1 buffer busy waits .01 5 db file sequential read .01 6 log file sync .01 10 write complete waits .04 36 free buffer waits .17 135 CPU .19 153 ------------------ ------- Sum .44
bsn08 buffer busy waits .02 26 log buffer space .04 47 log file sync .04 47 enqueue .05 52 db file scattered read .10 108 rdbms ipc reply .13 134 local write wait .15 160 db file sequential read .27 281 direct path write .30 309 direct path read .32 336 CPU .38 401 ------------------ ------- Sum 1.38
#.21Copyright 2006 Kyle Hailey
SASH – DB Detailed AAS@actAnalysis Begin Time : 2007-07-24 11:04:48Analysis End Time : 2007-07-24 11:19:45Start time, mins ago: 15Request Duration : 15Collections : 528Data Values : 3327Elapsed Time: 15 mins
WAIT_EVENT CNT % Active Ave_Act_Sess-------------------------------------- ---------- ------------latch free 10 .3 .02log buffer space 13 .39 .02buffer busy waits 14 .42 .03db file scattered read 15 .45 .03library cache pin 78 2.34 .15log file sync 213 6.4 .4ON CPU 726 21.82 1.38enqueue 855 25.7 1.62db file sequential read 1399 42.05 2.65 ------------sum 6.3
#.22Copyright 2006 Kyle Hailey
SASH – AAS over time@aveactTM NPTS AVEACT GRAPH CPU WAITS---------------- ------ ------- ---------------------- ---- -----06-AUG 13:00:00 270 .33 +- 2 29 5906-AUG 14:00:00 1040 2.24 ++--------2--- 341 198406-AUG 15:00:00 623 6.67 ++++------2---------- 438 371806-AUG 16:00:00 1088 2.59 ++--------2---- 335 248606-AUG 17:00:00 1104 1.26 ++----- 2 349 104306-AUG 18:00:00 1093 1.38 +++---- 2 663 84206-AUG 19:00:00 1012 1.74 ++------- 2 373 138806-AUG 20:00:00 1131 .99 +---- 2 304 82006-AUG 21:00:00 1111 1.22 ++----- 2 344 101206-AUG 22:00:00 1010 1.66 ++------ 2 414 125906-AUG 23:00:00 1120 1.08 +---- 2 298 91307-AUG 00:00:00 1024 .83 +--- 2 273 57607-AUG 01:00:00 1006 1.74 ++------- 2 319 142807-AUG 02:00:00 1090 2.47 ++--------2---- 347 234507-AUG 03:00:00 687 6.59 +++-------2---------- 382 414207-AUG 04:00:00 1004 1.95 ++++++--- 2 1299 65907-AUG 05:00:00 1104 3.08 +++++-----2------ 1170 222607-AUG 06:00:00 1122 1.91 +++++++-- 2 1582 55807-AUG 07:00:00 1115 1.06 +++--- 2 559 61807-AUG 08:00:00 1140 .81 ++-- 2 403 51907-AUG 09:00:00 1128 .88 ++--- 2 386 601
#.23Copyright 2006 Kyle Hailey
SASH – AAS over time with waits@aveactnTO_CHAR(STA AAS AAS1 FIRST AAS2 SECOND GRAPH
----------- ------- ----- --------------- ----- --------------- ------------------------06 13:00:00 .30 .11 db file sequent .10 CPU - 206 14:00:00 2.24 .87 direct path wri .49 log file sync ++--------2---06 15:00:00 6.67 2.07 direct path wri 1.93 log file sync ++++------2----------06 16:00:00 2.59 1.01 direct path wri .57 log file sync ++--------2----06 17:00:00 1.26 .63 log file sync .32 CPU ++----- 206 18:00:00 1.38 .61 CPU .45 log file sync +++---- 206 19:00:00 1.86 .97 log file sync .39 CPU ++------- 206 20:00:00 .99 .38 log file sync .27 CPU +---- 206 21:00:00 1.22 .57 log file sync .31 CPU ++----- 206 22:00:00 1.66 .81 log file sync .41 CPU ++------ 206 23:00:00 1.08 .49 log file sync .27 CPU +---- 207 00:00:00 .83 .37 log file sync .27 CPU +--- 207 01:00:00 1.74 .96 log file sync .31 CPU ++------- 207 02:00:00 2.48 1.21 direct path wri .52 log file sync ++--------2----07 03:00:00 6.59 2.63 direct path wri 1.58 log file sync +++-------2----------07 04:00:00 1.95 1.29 CPU .27 log file sync ++++++--- 207 05:00:00 3.08 1.05 CPU .83 enqueue +++++-----2------
#.24Copyright 2006 Kyle Hailey
Aveact.sql
#.25Copyright 2006 Kyle Hailey
““-” = WAIT-” = WAIT
““+” = CPU+” = CPU
which waits ? -> aveactn.sqlwhich waits ? -> aveactn.sql
#.26
Aveactn.sql
Copyright 2006 Kyle Hailey
#.27Copyright 2006 Kyle Hailey
SASH – SQL longest running @@longsql.sql
START_TIME COUNT(*) SQL_ID FIXED_TABLE_SEQUENCE TOPN ------------ ---------- ---------- -------------------- ---------- JUN-01 02:00 29 795857215 34254 1 JUN-01 02:00 29 795857215 34547 1 JUN-01 02:00 29 986013188 34305 1 JUN-01 02:15 105 452165714 35961 1 JUN-01 02:15 102 866152581 35999 2 JUN-01 02:30 119 2586830956 39017 1 JUN-01 02:30 109 452165714 39130 2
Using v$session fixed_table_sequence and sql_hash Using v$session fixed_table_sequence and sql_hash
#.28Copyright 2006 Kyle Hailey
ASHMON a free “OEM-lite” http://perfvision.com/ashmon.php 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 http://perfvision.com/sash.php
#.29
ASHMON
06/05/0806/05/08
#.30
Swingbench
Simulated DB activity http://www.dominicgiles.com
#.31
ASHMON Aggregates Drilldowns Time Slicing Guidance
3105/03/2305/03/23
#.32Copyright 2006 Kyle Hailey
CPU > Max CPU
#.33Copyright 2006 Kyle Hailey
Radical Change in Profile
#.34
$5K/CPU$5K/CPU
Oracle DatabaseOracle Database
=
Copyright 2006 Kyle Hailey
OEMOEM ASHMONASHMON
DB OptimizerDB Optimizer
HSQL – local DBHSQL – local DB
licensedlicensed
sys/systemsys/system
V$active_session_historyV$active_session_history
FreeFree
sashsash
V$active_session_historyV$active_session_history
FreeFree
$1500 unlimited
#.35Copyright 2006 Kyle Hailey
Quest – Performance Analyzer Good interface SGA direct access only
Good – fast, low impactBad – difficult to install and administer
#.36Copyright 2006 Kyle Hailey
Quest
#.37Copyright 2006 Kyle Hailey
Quest
#.38Copyright 2006 Kyle Hailey
Symantec’s I3 End to End monitoring Right Data Complicated to Install and administer
#.39Copyright 2006 Kyle Hailey
Symantec
#.40Copyright 2006 Kyle Hailey
Symantec I3
#.41Copyright 2006 Kyle Hailey
Symantec I3
#.42Copyright 2006 Kyle Hailey
Lab 128 Easy Fast Cheap Great data analysis Collects right information Complicated interface - “Geeks tool” No Analysis
#.43Copyright 2006 Kyle Hailey
Confio’s Ignite
#.44
DB Optimizer
Copyright 2006 Kyle Hailey
#.45Copyright 2006 Kyle Hailey
Lab128
#.46Copyright 2006 Kyle Hailey
Summary ToolsTools
Quest Performance Analyst
Confio’s Ignite Symantec’s I3 Lab128 DB Optimizer
Free but no graphics SASH
Your custom queries Simulated ASH
#.47
OEM DB Optimizer
Lab 128 SASH
performance $100,000 $1500 $500 free
SQL Tuning $100,000 included N/A N/A
Both $200,000 $1500 N/A N/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