zoukankan      html  css  js  c++  java
  • 如何找出Oracle instance中当前打开游标open cursor的总数?

    http://t.askmaclean.com/thread-1302-1-33.html

    如何找出Oracle instance中当前打开游标open cursor的总数?

    v$open_cursor  包括多种cursor:
    注意 11.2中  v$open_cursor 才有 cursor_type 这一字段 之前都没有 , 即无法分清楚 是open cursor 还是cached cursor 

    SQL> select distinct cursor_type from v$open_cursor;
    
    CURSOR_TYPE
    ----------------------------------------------------------------
    SESSION CURSOR CACHED
    OPEN
    OPEN-RECURSIVE
    DICTIONARY LOOKUP CURSOR CACHED
    BUNDLE DICTIONARY LOOKUP CACHED
    
    
    其中 部分是 CACHED的cursor 所以不能算作open cursor 
    
    
    可以利用以下查询近似 了解系统中 open cursor的总数, 
    
    SQL> select count(*)
      2    from v$open_cursor where cursor_type  in ('OPEN','OPEN-RECURSIVE');
    
      COUNT(*)
    ----------
            3

    11g 以前 使用以下查询

    SQL> select sum(a.value),b.name from v$sesstat a,v$statname b where a.statistic# = b.statistic# and b.name = 'opened cursors current' group by b.name;
    
    SUM(A.VALUE) NAME
    ------------ ----------------------------------------
             149 opened cursors current
    
    SQL> select * from v$sysstat where name like '%cursor%';
    
    STATISTIC# NAME                                          CLASS      VALUE    STAT_ID
    ---------- ---------------------------------------- ---------- ---------- ----------
             2 opened cursors cumulative                         1    5276872   85052502
             3 opened cursors current                            1        149 2301954928
             9 pinned cursors current                            1         22 2771133180
           295 session cursor cache hits                        64    3169224 3678609077
           296 session cursor cache count                       64    1427737  568260813
           321 cursor authentications                          128      28222 4069981174
    
    6 rows selected.

     通过以下脚本 可以获得 某个连接打开的游标数量

    select sum(a.value), b.name,a.sid
    from v$sesstat a, v$statname b
    where a.statistic# = b.statistic#
    and b.name = 'opened cursors current'
    group by rollup (b.name,a.sid)
    order by 1
    /

    通过以下脚本 可以获得 某个连接 session cached cursor 

    select a.value, s.username, s.sid, s.serial#
    from v$sesstat a, v$statname b, v$session s
    where a.statistic# = b.statistic#  and s.sid=a.sid
    and b.name = 'session cursor cache count'
    order by 1
    /
    Oracle、Linux、Unix
  • 相关阅读:
    两个链表的第一个公共结点
    数组中的逆序对
    C++强制类型转换运算符(static_cast、reinterpret_cast、const_cast和dynamic_cast)
    第一个只出现一次的字符
    机器学习算法速览表
    丑数
    设计模式---行为型设计模式【策略模式】
    设计模式---行为型设计模式【备忘录模式】
    设计模式----创建型设计模式【单例模式】
    设计模式----创建型设计模式【简单工厂、工厂方法、抽象工厂】
  • 原文地址:https://www.cnblogs.com/taowang2016/p/3068616.html
Copyright © 2011-2022 走看看