您好,登錄后才能下訂單哦!
這篇文章主要介紹“Oracle動態視圖v$active_session_history怎么應用”的相關知識,小編通過實際案例向大家展示操作過程,操作方法簡單快捷,實用性強,希望這篇“Oracle動態視圖v$active_session_history怎么應用”文章能幫助大家解決問題。
Samples of wait event information are taken once per second and made available using the V$ACTIVE_SESSION_HISTORY view. An active session is one that is waiting on CPU or any event that does not belong to the "Idle" wait class at the time of the sample. The sample information is written to a circular buffer in the SGA, so the greater the database activity, the less time the information will remain available for.
有幾個關鍵點:1秒采集一次,執行時間很快遠小于1秒的SQL基本不會采集到,只寫入非空閑狀態的事件,循環存放活動越多保存的時間就越短。
v$active_session_history的字段非常豐富,實際工作中主要應用在下面這些情況:
a.應用場景:開發反應2023-03-02 00:22至00:35,數據落盤慢,根據情況查看此時間段的主要活動事件,數量,與sql_id(全局) select count(*), sql_id, event, blocking_session from gv$active_session_history where sample_time between to_date('2023-03-02 00:22:00', 'yyyy-mm-dd hh34:mi:ss') and to_date('2023-03-02 00:35:00', 'yyyy-mm-dd hh34:mi:ss') group by sql_id, event, blocking_session order by 1; (非全局)BLOCKING_INST_ID--被阻塞者, blocking_session--阻塞者 select count(*), sql_id, event, BLOCKING_INST_ID, blocking_session from v$active_session_history where sample_time between to_date('2023-03-02 00:20:00', 'yyyy-mm-dd hh34:mi:ss') and to_date('2023-03-02 00:35:00', 'yyyy-mm-dd hh34:mi:ss') group by sql_id, event, BLOCKING_INST_ID, blocking_session order by 1; b.現在我們已經得到兩個關鍵信息:sql_id與阻塞事件,首先根據sql_id我們可以再進一步使用此視圖,實際中可以多調整幾個較小的時間段,以突出最有代表的信息 select count(*), session_id, session_serial#, sql_id, event, BLOCKING_INST_ID, blocking_session from v$active_session_history where sample_time between to_date('2023-03-02 00:24:00', 'yyyy-mm-dd hh34:mi:ss') and to_date('2023-03-02 00:25:00', 'yyyy-mm-dd hh34:mi:ss') and sql_id = '1xfbtdvu3xb67' group by session_id, session_serial#, sql_id, event, BLOCKING_INST_ID, blocking_session order by 3; c.加入等待事件后更清晰 select count(*), session_id, sql_id, event, BLOCKING_INST_ID, blocking_session from v$active_session_history where sample_time between to_date('2023-03-02 00:25:00', 'yyyy-mm-dd hh34:mi:ss') and to_date('2023-03-02 00:35:00', 'yyyy-mm-dd hh34:mi:ss') and event = 'library cache lock' and sql_id = '1j47z0mc6k02b' group by session_id, sql_id, event, BLOCKING_INST_ID, blocking_session order by 1; 結論:可以看出大量并發等待,最終是發現有什么阻塞了此SQL語句
當然也要結合我們的AWR報告:(兩份為同時間段,上一份為有爭用,下一份為正常情況,報告太長,只截取了關鍵點)
最后關鍵點a:下面報告里的sql_id與事件與v$active_session_history里查出來的結果相同,進一步證明事件與此SQL的關聯性。
總結時間:
我們根據SQL_ID找到相應的SQL語句,從而找到對應的TABLE,最終對應到兩張分區表,分別為:AA_BBB_CCCC_DDDD_OUT,AA_BBB_CCCC_DDDD_IN。
#根據dba_objects確定創建時間是否匹配 select owner, object_name, object_type, to_char(created, 'yyyy-mm-dd hh34:mi:ss') from dba_objects where object_name = 'AA_BBB_CCCC_DDDD_OUT' and created > to_date('2023-03-01', 'yyyy-mm-dd') order by 4; select owner, object_name, object_type, to_char(created, 'yyyy-mm-dd hh34:mi:ss') from dba_objects where object_name = 'AA_BBB_CCCC_DDDD_IN' and created > to_date('2023-03-01', 'yyyy-mm-dd') order by 4;
關于“Oracle動態視圖v$active_session_history怎么應用”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識,可以關注億速云行業資訊頻道,小編每天都會為大家更新不同的知識點。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。