How to find Current open Cursors in Oracle

前端 未结 6 2195
悲&欢浪女
悲&欢浪女 2020-12-05 02:13

What is the query to find the no. of current open cursors in an Oracle Instance?

Also, what is the accuracy/update frequency of this data?

I am using Oracle

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 03:02

    Here's how to find open cursors that have been parsed. You need to be logged in as a user with access to v$open_cursor and v$session.

    COLUMN USER_NAME FORMAT A15
    
    SELECT s.machine, oc.user_name, oc.sql_text, count(1) 
    FROM v$open_cursor oc, v$session s
    WHERE oc.sid = s.sid
    GROUP BY user_name, sql_text, machine
    HAVING COUNT(1) > 2
    ORDER BY count(1) DESC
    ;
    

    If gives you part of the SQL text so it can be useful for identifying leaky applications. If a cursor has not been parsed, then it does not appear here. Note that Oralce will sometimes keep things open longer than you do.

提交回复
热议问题