SELECT o.object_name,
o.object_type,
a.event,
SUM(a.wait_time + a.time_waited) total_wait_time
FROM v$active_session_history a, dba_objects o
WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE
AND a.current_obj# = o.object_id
GROUP BY o.object_name, o.object_type, a.event
ORDER BY total_wait_time;
--列出数据库中最后15分钟内最重要的等待事件SELECT a.event,
SUM(a.wait_time + a.time_waited) total_wait_time
FROM v$active_session_history a
WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE
GROUP BY a.event
ORDER BY total_wait_time DESC;
--等待最多的用户SELECT s.sid,
s.username,
SUM(a.wait_time + a.time_waited) total_wait_time
FROM v$active_session_history a,v$session s
WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE
AND a.session_id = s.sid
GROUP BY s.sid,s.username
ORDER BY total_wait_time DESC;
--确定等待最多的sqlSELECT a.user_id,
s.sql_text,
d.username,
SUM(a.wait_time + a.time_waited) total_wait_time
FROM v$active_session_history a, v$sqlarea s, dba_users d
WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE
AND a.sql_id = s.sql_id
AND a.user_id = d.user_id
GROUP BY a.user_id, s.sql_text, d.username;
dba_hist_active_sess_history:每60分钟,MMON后台进程都要刷新过滤了得ASH数据到磁盘,使其成为按小时的AWR快照的一部分。若ASH缓冲区已满,
则MMML后台进程进行数据的刷新。ASH数据被刷新到磁盘后,就不能在v$active_session_history视图中看到它了。此时要查看历史数据,就必须通过
dba_hist_active_sess_history视图。
段级动态性能视图:使用它们可以找出哪些表和索引正在使用大量资源或具有大量的等待。
v$segstat_name
v$segstat
v$segment_statistics
oracle一视图性能问题
标签: