Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find Current open Cursors in Oracle

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

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

I am using Oracle 10gR2

like image 498
M.N Avatar asked Jun 18 '09 05:06

M.N


People also ask

How do I check my open cursors?

You want to display open cursors in Oracle. We can query the data dictionary to determine the number of cursors that are open per session. "V$SESSION" provides a more accurate number of the cursors currently open than "V$OPEN_CURSOR".

How many cursors are open in Oracle?

The cursor count is per session. The Oracle parameter open_cursors sets the maximum number of cursors per session. A cusror can be thought of as a sql statement. So if 100 cursors are open it would indicate that a process has 100 sql statements open simultaneously.

What is open cursor in Oracle database?

OPEN cursor_name; In this syntax, the cursor_name is the name of the cursor declared in the declaration section. When you open a cursor, Oracle parses the query, binds variables, and executes the associated SQL statement.

How do I close all open cursors in Oracle?

Yes, closing/killing a session will close any related cursors. Don't use DBMS_SHARED_POOL. PURGE!


1 Answers

Total cursors open, by session:

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 = 'opened cursors current'; 

Source: http://www.orafaq.com/node/758

As far as I know queries on v$ views are based on pseudo-tables ("x$" tables) that point directly to the relevant portions of the SGA, so you can't get more accurate than that; however this also means that it is point-in-time (i.e. dirty read).

like image 171
Jeffrey Kemp Avatar answered Sep 20 '22 19:09

Jeffrey Kemp