Open cursor count is too high [message #418826] |
Tue, 18 August 2009 11:52 |
dasuwal@gmail.com
Messages: 20 Registered: June 2009
|
Junior Member |
|
|
Hi Forum
I am runing into a issue where an application opens 2200 active cursors with around 12 spawning sessions on a 10 cpu machine. The max_cursor parametere is increased to 3000. I am in discussion phase with developers to finetune the code to decrease the active cursors (but as usual they blame it a DB issue).
The high usage of cursor just choke the database and there are serious performance issues.
Can anyone please guide the pitfalls that may result due to such a high cursor usage.
Any advice on this matter is most welcome.
Thanks,
Danny.
|
|
|
|
|
|
|
Re: Open cursor count is too high [message #418880 is a reply to message #418826] |
Wed, 19 August 2009 00:24 |
trantuananh24hg
Messages: 744 Registered: January 2007 Location: Ha Noi, Viet Nam
|
Senior Member |
|
|
Said Thomas right, you might consider about his words.
Then, I support to you 2 script to detect the opening cursors.
1. Total open cursors by session
--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';
2. Total open cursors by username
SELECT SUM (a.VALUE) total_cur, AVG (a.VALUE) avg_cur, MAX (a.VALUE)
max_cur,
s.username, s.machine
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'
GROUP BY s.username, s.machine
ORDER BY 1 DESC;
SELECT MAX (a.VALUE) AS highest_open_cur, p.VALUE AS max_open_cur
FROM v$sesstat a, v$statname b, v$parameter p
WHERE a.statistic# = b.statistic#
AND b.NAME = 'opened cursors current'
AND p.NAME = 'open_cursors'
GROUP BY p.VALUE;
SELECT 'session_cached_cursors' parameter, LPAD (VALUE, 5) VALUE,
DECODE (VALUE,
0, ' n/a',
TO_CHAR (100 * used / VALUE, '990') || '%'
) USAGE
FROM (SELECT MAX (s.VALUE) used
FROM v$statname n, v$sesstat s
WHERE n.NAME = 'session cursor cache count'
AND s.statistic# = n.statistic#),
(SELECT VALUE
FROM v$parameter
WHERE NAME = 'session_cached_cursors')
UNION ALL
SELECT 'open_cursors', LPAD (VALUE, 5),
TO_CHAR (100 * used / VALUE, '990') || '%'
FROM (SELECT MAX (SUM (s.VALUE)) used
FROM v$statname n, v$sesstat s
WHERE n.NAME IN
('opened cursors current', 'session cursor cache count')
AND s.statistic# = n.statistic#
GROUP BY s.SID),
(SELECT VALUE
FROM v$parameter
WHERE NAME = 'open_cursors')
/
Hope to help you!
|
|
|