我来说说 监控 oracle session

This I will highlight the oracle session monitor:

  I will do a workshop to begin this:

Step1:

  Open one session to update one row data:
 
SQL> select * from t1;

        ID
----------
      1981
      2012

SQL> update t1 set id=20000 where id=1981;

已更新 1 行。

Step2:
 Open another session to update the same row:
 
 SQL> update t1 set id=10000 where id=1981;
...(waiting...)

Step3:
  Open one session to review the session_wait view:
 
  SQL> select sid,wait_class from v$session_wait;

       SID WAIT_CLASS
---------- ----------------------------------------------------------------
       134 Idle
       136 Idle
       138 Idle
       141 Idle
       143 Idle
       147 Idle
       148 Idle
       149 Application
       150 Network
       151 Idle
       156 Idle

       SID WAIT_CLASS
---------- ----------------------------------------------------------------
       157 Idle
       158 Idle
       159 Idle
       160 Idle
       161 Idle
       162 Idle
       163 Idle
       164 Idle
       165 Idle
       166 Idle
       167 Idle

       SID WAIT_CLASS
---------- ----------------------------------------------------------------
       168 Idle
       169 Idle
       170 Idle

已选择25行。

SQL> select sid,EVENT from v$session_wait WHERE SID=149;

       SID EVENT
---------- ----------------------------------------------------------------
       149 enq: TX - row lock contention
      
Step 4:
  Let rollback in session 150, the session : 149 will commit automatic:
 
  SQL> SELECT *FROM V$MYSTAT WHERE ROWNUM <2;

       SID STATISTIC#      VALUE
---------- ---------- ----------
       150          0          1

SQL> ROLLBACK;

回退已完成。

SQL> update t1 set id=10000 where id=1981;

已更新 1 行。

SQL> SELECT * FROM V$MYSTAT WHERE ROWNUM <2;

       SID STATISTIC#      VALUE
---------- ---------- ----------
       149          0          1
      
Step5:

  Let us look into the review : v$session_wait:
  SQL> select sid,wait_class from v$session_wait;

       SID WAIT_CLASS
---------- ----------------------------------------------------------------
       134 Idle
       136 Idle
       138 Idle
       141 Idle
       143 Idle
       147 Idle
       148 Idle
       149 Idle
       150 Network
       151 Idle
       156 Network

       SID WAIT_CLASS
---------- ----------------------------------------------------------------
       157 Idle
       158 Idle
       159 Idle
       160 Idle
       161 Idle
       162 Idle
       163 Idle
       164 Idle
       165 Idle
       166 Idle
       167 Idle

       SID WAIT_CLASS
---------- ----------------------------------------------------------------
       168 Idle
       169 Idle
       170 Idle

已选择25行。

The waiting session will missing.

Step6:
  If we want to analyze the wait event, what I can do?
 
  1:The Oracle provide us one dictinary:
   v$session_wait_history;
   (this dictionary will only keep latest 10 records)
 
  2:Oracle also provide another dictionry:
    v$active_session_history
   
  3:If the Database down or restart, you can view the dictionary:
  dba_hist_active_sess_history
  (the head with "dba" can write down by hard disk, the other are call from memory)
 
Step7:
  You can also use EM to monitor the database session.
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shenghuiping2001

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值