--racle Database 10g V$SYSMETRIC view contains several excellent response-time metrics select from where METRIC_NAME

, VALUE SYS.V_$SYSMETRIC METRIC_NAME IN ('Database CPU Time Ratio', 'Database Wait Time Ratio') AND INTSIZE_CSEC = (select max(INTSIZE_CSEC) from SYS.V_$SYSMETRIC);

-- Last one hour metrics select end_time, value from sys.v_$sysmetric_history where metric_name = 'Database CPU Time Ratio' order by 1; --minimum, maximum, and average values of overall database efficiency by querying the V$SYSMETRIC_SUMMARY view with a query such as this: select CASE METRIC_NAME WHEN 'SQL Service Response Time' then 'SQL Service Response Time (secs)' WHEN 'Response Time Per Txn' then 'Response Time Per Txn (secs)' ELSE METRIC_NAME END METRIC_NAME, CASE METRIC_NAME WHEN 'SQL Service Response Time' then ROUND((MINVAL / 100),2) WHEN 'Response Time Per Txn' then ROUND((MINVAL / 100),2) ELSE MINVAL END MININUM, CASE METRIC_NAME WHEN 'SQL Service Response Time' then ROUND((MAXVAL / 100),2) WHEN 'Response Time Per Txn' then ROUND((MAXVAL / 100),2) ELSE MAXVAL END MAXIMUM, CASE METRIC_NAME WHEN 'SQL Service Response Time' then ROUND((AVERAGE / 100),2) WHEN 'Response Time Per Txn' then ROUND((AVERAGE / 100),2) ELSE AVERAGE END AVERAGE from SYS.V_$SYSMETRIC_SUMMARY where METRIC_NAME in ('CPU Usage Per Sec',

'Executions Per Sec'. (select round((value / 1000000).v_$sys_time_model where stat_name = 'DB time').'DB CPU')).plsql_time when 'parse time elapsed' then time_secs . case db_stat_name when 'sql execute elapsed time' then time_secs . 'Database Wait Time Ratio'.v_$sys_time_model where stat_name = 'PL/SQL execution elapsed time'). case db_stat_name when 'sql execute elapsed time' then round(100 * (time_secs . 'background cpu time'. 'Executions Per Txn'. (select round((value / 1000000). 'User Transaction Per Sec') ORDER BY 1.hard_parse_time else time_secs end time_secs.3) time_secs from sys. 'Response Time Per Txn'.v_$sys_time_model where stat_name = 'hard parse elapsed time') order by 2 desc.2) when 'parse time elapsed' then round(100 * (time_secs .v_$sys_time_model where stat_name not in('DB time'. 'Database CPU Time Ratio'. --to view individual wait events to understand waits and bottlenecks . select case db_stat_name when 'parse time elapsed' then 'soft parse time' else db_stat_name end db_stat_name.'CPU Usage Per Txn'. 'SQL Service Response Time'.3) hard_parse_time from sys. (select round((value / 1000000).3) db_time from sys. round((value / 1000000).hard_parse_time) / db_time.3) plsql_time from sys.'background elapsed time'.2) else round(100 * time_secs / db_time.plsql_time) / db_time.2) end pct_time from (select stat_name db_stat_name.

username. --wait classes in these two modified views with Oracle Database 10g. TOTAL_WAITS. --view current session wait activity using the new wait classes using the following query: select a.sid. b.v_$active_session_history a.2) time_waited_secs from sys.name wait_event. (select sum(TOTAL_WAITS) SUM_WAITS. ROUND((TIME_WAITED / 100). username.dba_users c . b.2) PCT_WAITS. decode(session_type.username is not null and a.session_type. round(100 * (TOTAL_WAITS / SUM_WAITS). sys.wait_class.wait_class != 'Idle' order by 5 desc. a.program program.'background'. round((a.2) PCT_TIME from (select WAIT_CLASS.total_waits.time_waited) sess_time from sys.use rname) username. sess_time.sid and b.2) TIME_WAITED_SECS. a. round(100 * (TIME_WAITED / SUM_TIME). TIME_WAITED from V$SYSTEM_WAIT_CLASS where WAIT_CLASS != 'Idle').v_$session_wait_class a. sys.c. select sess_id.2) pct_time_waited from (select a. program.select WAIT_CLASS. sum(TIME_WAITED) SUM_TIME from V$SYSTEM_WAIT_CLASS where WAIT_CLASS != 'Idle') order by 5 desc.session_id sess_id.v_$event_name b. a. sum(a. sys.time_waited / 100).v_$session b where b. TOTAL_WAITS.sid = a. wait_event. round(100 * (sess_time / total_time).

v_$active_session_history a. -. a.program.wait_class = 'User I/O' group by a. sys.user_id = c. --query to get the individual wait events associated with the query along with the corresponding wait times.where a.event# and sample_time > '21-NOV-04 12:00:00 AM' and sample_time < '21-NOV-04 05:00:00 AM' and b.files.object_id and time_waited <> 0. time_waited. elapsed_time. owner. decode(session_type. object_name.session_type.v_$sqlarea order by 5 desc) where rownum < 6.event# and a.use rname).wait_class = 'User I/O') order by 6 desc.user_id and sample_time > '21-NOV-04 12:00:00 AM' and sample_time < '21-NOV-04 05:00:00 AM' and b.current_obj# = b. --top five SQL statements with the highest user I/O waits select * from (select sql_text.'background'.time_waited) total_time from sys.event# = b. sql_id.v_$event_name b where a.c.and objects that were the source of those waits: select event. . current_file#.session_id. (select sum(a.v_$active_session_history a. b. cpu_time. current_block# from sys. user_io_wait_time from sys.name).dba_objects b where sql_id = '6gvch1xu9ca3g' and a. sys.event# = b.

Sign up to vote on this title
UsefulNot useful