真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網站制作重慶分公司

數(shù)據庫中如何查看歷史會話等待事件對應的session信息

小編給大家分享一下數(shù)據庫中如何查看歷史會話等待事件對應的session信息,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

創(chuàng)新互聯(lián)公司主要業(yè)務有網站營銷策劃、成都網站建設、網站制作、微信公眾號開發(fā)、重慶小程序開發(fā)、H5技術、程序開發(fā)等業(yè)務。一次合作終身朋友,是我們奉行的宗旨;我們不僅僅把客戶當客戶,還把客戶視為我們的合作伙伴,在開展業(yè)務的過程中,公司還積累了豐富的行業(yè)經驗、營銷型網站資源和合作伙伴關系資源,并逐漸建立起規(guī)范的客戶服務和保障體系。 

此處以enq: TX - row lock contention等待時間為例。


如果在此回話發(fā)生在awr快照信息默認的保存天數(shù)以內。
可以通過如下sql查詢到相關的session信息。
select * from DBA_HIST_ACTIVE_SESS_HISTORY where event like '%enq: TX - row lock contention%'

DBA_HIST_ACTIVE_SESS_HISTORY 中的blocking_session字段關聯(lián)DBA_HIST_ACTIVE_SESS_HISTORY中的session_id找到對應的sql_id從而得到回話信息。

可以通過如下查詢直接獲取信息:
select t.instance_number,
       t.sample_time,
       lpad('-', 2 * (level - 1), '-') || t.client_id,
       t.session_id,
       t.blocking_session,
       t.session_serial#,
       t.sql_id,
       t.event,
       t.session_state,
       level,
       connect_by_isleaf,
       connect_by_iscycle
  from dba_hist_active_sess_history  t
 where snap_id between 36878 and 36879
 start with blocking_session is not null
        and event like 'enq: TX - row lock contention%'
connect by nocycle sample_time = prior sample_time
       and session_id = prior blocking_session
       and session_serial# = prior blocking_session_serial#


其中blocking session為正在阻塞該回話的session


實戰(zhàn)案例:
查看等待事件為行鎖的session
select a.snap_id,
       a.sql_id,
       a.session_id,
       a.session_serial#,
       a.blocking_session,
       a.blocking_session_serial#,
       a.blocking_session_status
  from DBA_HIST_ACTIVE_SESS_HISTORY a
 where event like '%enq: TX - row lock contention%'
   and snap_id between 20399 and 20400


編寫子查詢,查看阻塞回話,并統(tǒng)計阻塞次數(shù)
select a.blocking_session,
       a.blocking_session_serial#,
       count(a.blocking_session)
  from DBA_HIST_ACTIVE_SESS_HISTORY a
 where event like '%enq: TX - row lock contention%'
   and snap_id between 20399 and 20400
 group by a.blocking_session, a.blocking_session_serial#
 order by 3 desc
 
查看阻塞回話的sql_id和被阻塞的sql_id,條件為阻塞大于19次的
select distinct b.sql_id,c.blocked_sql_id
  from DBA_HIST_ACTIVE_SESS_HISTORY b,
       (select a.sql_id as blocked_sql_id,
       a.blocking_session,
               a.blocking_session_serial#,
               count(a.blocking_session)
          from DBA_HIST_ACTIVE_SESS_HISTORY a
         where event like '%enq: TX - row lock contention%'
           and snap_id between 20399 and 20400
         group by a.blocking_session, a.blocking_session_serial#,a.sql_id
        having count(a.blocking_session) > 19
         order by 3 desc) c
 where b.session_id = c.blocking_session
   and b.session_serial# = c.blocking_session_serial#
   and b.snap_id between 20399 and 20400

動態(tài)性能視圖注釋:

V$ACTIVE_SESSION_HISTORY displays sampled session activity in the database. It contains snapshots of active database sessions taken once a second. A database session is considered active if it was on the CPU or was waiting for an event that didn't belong to the Idle wait class. Refer to the V$EVENT_NAME view for more information on wait classes.

看完了這篇文章,相信你對“數(shù)據庫中如何查看歷史會話等待事件對應的session信息”有了一定的了解,如果想了解更多相關知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!


網頁標題:數(shù)據庫中如何查看歷史會話等待事件對應的session信息
轉載源于:http://weahome.cn/article/ijgjjg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部