初始化参数OPEN_CURSORS的理解加深

以前一直有些迷惑,一直以为v$open_cursor里查询出来就是当前open的cursor,google收藏了一些讨论得比较深入的帖,比如说这里: 。[@more@]
今天看到Natalka Roshak写的一篇关于open_cursors及session_cached_cursors的文章,顿时一目了然,参见:,摘录部分精彩内容如下:

SESSION_CACHED_CURSORS sets the number of cached closed cursors each session can have. You can set SESSION_CACHED_CURSORS to higher than OPEN_CURSORS, lower than OPEN_CURSORS, or anywhere in between. This parameter has no effect on ora-1000’s or on the number of cursors a session will have open. Conversely, OPEN_CURSORS has no effect on the number of cursors cached. There’s no relationship between the two parameters.

If SESSION_CACHED_CURSORS is not set, it defaults to 0 and no cursors will be cached for your session. (Your cursors will still be cached in the shared pool, but your session will have to find them there.) If it is set, then when a parse request is issued, Oracle checks the library cache to see whether more than 3 parse requests have been issued for that statement. If so, Oracle moves the session cursor associated with that statement into the session cursor cache. Subsequent parse requests for that statement by the same session are then filled from the session cursor cache, thus avoiding even a soft parse. (Technically, a parse can’t be completely avoided; a “softer” soft parse is done that’s faster and requires less CPU.)
这里提到的softer soft parse与 这里8#里biti_rainy老大提到的软软解析就是一个意思了,之前我卡在这里挺迷糊,现下算是弄明白了。

更加大快人心的句子来了:
I believe a lot of the confusion about open cursors vs. cached cursors comes from the names of the Oracle dynamic performance views used to monitor them. v$open_cursor shows cached cursors, not currently open cursors, by session. If you’re wondering how many cursors a session has open, don’t look in v$open_cursor. It shows the cursors in the session cursor cache for each session, not cursors that are actually open.

To monitor open cursors, query v$sesstat where name=‘opened cursors current’. This will give the number of currently opened 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';

sigh,按这种思路做了几个实验,有点阔然开朗的感觉。
比如,用toad连接到一个库,在Editor里多开几个tab(此时session sid均是一致),分别在tab里运行一些sql,在其中一个tab里查询open的cursor数量,发现此时open的cursor数量即等于打开的tab数量。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值