91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

V$ACTIVE_SESSION_HISTORY視圖的使用

發布時間:2020-08-18 00:01:53 來源:ITPUB博客 閱讀:752 作者:pentium 欄目:關系型數據庫

V$ACTIVE_SESSION_HISTORY 顯示數據庫中的采樣會話活動。ASH每秒從v$session中取快照,存在V$ACTIVE_SESSION_HISTORY中,并收集所有活動會話的等待信息。若ASH數據被刷新到磁盤,則需要從DBA_HIS_ACTIVE_SESS_HISTORY視圖中查詢相關信息。


該視圖是ASH的核心,用以記錄活動SESSION的歷史等待信息,每秒采樣一次,這部分內容記錄在內存中,期望值是記錄一個小時的內容。

用法舉例:查找最近一分鐘內,最消耗CPU的sql語句

SELECT sql_id, count(*), round(count(*) / sum(count(*)) over(), 2) pctload

 FROM V$ACTIVE_SESSION_HISTORY

WHERE sample_time > sysdate – 1 / (24 * 60)

   AND session_type <> 'BACKGROUND’

   AND session_state = 'ON CPU’

GROUP BY sql_id

 ORDER BY count(*) desc;


用法舉例:查找最近一分鐘內,最消耗I/O的sql語句

SELECT ash.sql_id,count(*)

 FROM V$ACTIVE_SESSION_HISTORY ASH,V$EVENT_NAME EVT

WHERE ash.sample_time > sysdate -1/(24*60)

   AND ash.session_state = 'WAITING’

   AND ash.event_id = evt.event_id

   AND evt.wait_class = 'USER I/O’

GROUP BY ash.sql_id

 ORDER BY count(*) desc;


用法舉例:查找最近一分鐘內,最消耗CPU的session

SELECT session_id,count(*)

 FROM V$ACTIVE_SESSION_HISTORY

WHERE session_state = 'ON CPU’

   AND sample_time > sysdate -1/(24*60)

GROUP BY session_id

ORDER BY count(*) desc;


用法舉例:查找最近一分鐘內,最消耗資源的sql語句

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# and ash.sample_time > sysdate -1/(24*60)

GROUP BY ash.sql_id

 ORDER BY sum(decode(ash.session_state,'ON CPU’,1,1)) desc;


用法舉例:查找最近一分鐘內,最消耗資源的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(ash.session_state,'ON CPU’,1,1)) “TOTAL”

 FROM V$ACTIVE_SESSION_HISTORY ASH,V$EVENT_NAME EN

WHERE en.event# = ash.event# and ash.sample_time > sysdate -1/(24*60)

GROUP BY ash.session_id,ash.user_id,ash.session_serial#,ash.program

 ORDER BY sum(decode(ash.session_state,'ON CPU’,1,1))

--------------------- 



在數據庫出現性能問題的時候使用awr,ash,addm都是不錯的選擇,實際上直接查詢v$active_session_history也能很快定位解決問題。
實際上如果查看v$active_session_history視圖,結合一些視圖可以獲取許多信息。
舉幾個例子來說明:

1.確定那個對象有高的等待:
SELECT   a.current_obj#, 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 / 1440 AND SYSDATE AND a.current_obj# = o.object_id
GROUP BY a.current_obj#, o.object_name, o.object_type, a.event
ORDER BY total_wait_time desc ; 2.看看一段時間主要是那些等待事件:
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 / 1440 AND SYSDATE
GROUP BY a.event
ORDER BY total_wait_time DESC; 3.看看那個回話有問題:
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 / 1440 AND SYSDATE AND a.session_id = s.SID
GROUP BY s.SID, s.username
ORDER BY total_wait_time DESC;
--當然這個只能查詢最近的會準一點,回話退出就不行了。

4.看看那個sql語句有問題。
SELECT   a.user_id, d.username, s.sql_text, 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 - 15 / 1440 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
order by  SUM (a.wait_time + a.time_waited) desc 

-- 這里查詢的是v$sqlarea視圖。 同樣你可以使用視圖DBA_HIST_ACTIVE_SESS_HISTORY代替v$active_session_history查詢歷史的信息。

select * from dba_objects where wner='SYS' and object_name like 'DBA_HIST%' and object_type='VIEW';

利用這些視圖定位許多信息問題



向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

治多县| 遂溪县| 宝应县| 历史| 盘锦市| 大关县| 庄浪县| 安新县| 基隆市| 祥云县| 南昌县| 海兴县| 宣威市| 长葛市| 斗六市| 新兴县| 秀山| 安溪县| 渝北区| 曲周县| 岳池县| 太保市| 衢州市| 公安县| 丰都县| 惠水县| 板桥市| 循化| 内黄县| 屯昌县| 吐鲁番市| 长白| 称多县| 牟定县| 从化市| 洪江市| 邹城市| 夏津县| 万荣县| 靖远县| 长岛县|