SQL> select count(*) from v$open_cursor ; COUNT(*) ---------- 350SQL> select * from v$sysstat 2 where name = 'opened cursors current'; STATISTIC# NAME ---------- -------------------------------------------------------- CLASS VALUE STAT_ID ---------- ---------- ---------- 3 opened cursors current 1 67 2301954928
STATISTIC# NAME CLASS VALUE STAT_ID ---------- ---------------------------------------------------------------- ---------- ---------- ---------- 3 opened cursors current 1 65 2301954928
(1)这个情况是比较常见的。 (2)第二种情况通常会建议使用绑定变量,或者用简单的加大shared_pool,临时的解决方法就是alter system flush shared_pool。
2. Large_pool,Java_pool太小造成的
(1)这个通过错误信息的提示很容易判断(Ora-04031 cannot allocate .. memeory in [large_pool]) (2)解决方法就是简单的加大 Large_pool or Java_pool
3. 过度的开CURSOR而不关闭。
目前,此问题发生的越来越多,特别是在JAVA的运行环境中,屡见不鲜。加大Shared_pool或者flush shared_pool往往只能延迟问题出现的时间,而无法避免此问题。 判断方法:
select count(*) from v$open_cursor ;
select * from v$sysstat
where name = 'opened cursors current';
假如出来的值特大(以万为单位)时,基本就可以确定是这个原因了。 解决这个问题的方法就是检查程序,看是否没有正常的关闭cursor(对于JAVA来说,就是没有关闭Statement)。或者select sql_text from v$open_cursor,看看都是哪些cursor没关闭,再去检查车程序。 也有的程序使用了保持一定量的cursor一直open,从而避免cursor过多次的开启,来提高性能。对于这种情况,则应该选择适当的shared_pool_size和控制keep_opening的cursor的量。 另外,Oracle参数session_cached_cursors也有可能过大,解决的方法就是把它降低到适当的值。
----------
350SQL> select * from v$sysstat
2 where name = 'opened cursors current'; STATISTIC# NAME
---------- --------------------------------------------------------
CLASS VALUE STAT_ID
---------- ---------- ----------
3 opened cursors current
1 67 2301954928
---------- ---------------------------------------------------------------- ---------- ---------- ----------
3 opened cursors current 1 65 2301954928