← Sessions & Locks
Oracle · Sessions & Locks

How to check open cursors per session in Oracle

Count open cursors per Oracle session and compare against OPEN_CURSORS to catch leaks before ORA-01000.

Tested on11g12c18c19c21c23ai26ai

Cursor leaks surface as ORA-01000 (maximum open cursors exceeded). This ranks sessions by open cursor count and shows how close each is to the OPEN_CURSORS parameter.

SELECT o.sid, s.username, s.machine, s.program,
       COUNT(*) AS open_cursors,
       (SELECT value FROM v$parameter WHERE name = 'open_cursors') AS "LIMIT"
FROM   v$open_cursor o
JOIN   v$session     s ON s.sid = o.sid
GROUP BY o.sid, s.username, s.machine, s.program
ORDER BY open_cursors DESC;
cursorsv$open_cursorora-01000