oracle 游标一直涨,大量插入数据的操作老是报游标数超出最大数,怎么回事?...

1、Tuning at the DATABASE LEVEL

There is a parameter you can set in the init.ora that determines the number of cursors a user can open in a session: OPEN_CURSORS.

To solve the ORA-01000 error, set the OPEN_CURSORS to a higher number (such as 255).

Consequences to changing this parameter:

This parameter does not effect performance in any way but Oracle will now need a little more memory to store the cursors.

(在init.ora里将OPEN_CURSORS的值增大,目前生产数据库是800,此参数对性能不影响)

2、Tuning at the APPLICATION LEVEL

There are three parameters that affect handling cursors at the application level: RELEASE_CURSOR, HOLD_CURSOR, MAXOPENCURSORS. You should set these parameters at the precompiler level.

HOLD_CURSOR by default is NO. This means that after Oracle executes a SQL statement the links to the cursor cache, memory, and parse locks are released and marked for reuse. For more details refer to Programmer's Guide to Precompilers.

RELEASE_CURSOR by default is NO. This means that after Oracle executes a SQL statement, the links to the cursor cache is maintained and not released. For more information, refer to Programmer's Guide to Precompilers.

These two parameters must be used in conjunction for them to be effective. Here is a table that shows how settings of the two parameters interact.

(在应用层上调整RELEASE_CURSOR,HOLD_CURSOR,MAXOPENCURSORS。HOLD_CURSOR default=NO,执行语句后标记为重用,RELEASE_CURSOR default=NO,执行语句后保留,RELEASE_CURSOR,HOLD_CURSOR是相互联合影响的

----------------------------------------------------

|HOLD_CURSOR | RELEASE_CURSOR | LINKS ARE... |

----------------------------------------------------

| NO | not applicable | marked as reusable |

| YES | NO | maintained |

| NO | YES | removed immediately|

| n/a | YES | removed immediately|

----------------------------------------------------

)

To resolve the ORA-01000 error, you should set HOLD_CURSOR=NO and

RELEASE_CURSOR=YES. This way, after the cursors are used, Oracle will free up the memory for other cursors.

Consequences of setting these parameters HOLD_CURSOR=NO and RELEASE_CURSOR=YES:

This will cause Oracle to release the links and locks for each cursor after the SQL statement is executed. This means that the next time Oracle needs to issue the same SQL statement, Oracle will have to reparse the statement, and rebuild the execution plan. This will cause some performance overhead.

(可以设置HOLD_CURSOR=NO and RELEASE_CURSOR=YES来解决错误,这时候游标cursor使用后将释放内存,所带来的就是下一次执行同样的SQL需要更长的时间,性能下降)

对于下面这个maxopencursors参数不是很理解……而且不知道这些参数在那儿设置。希望大家能够有所帮助,谢谢!

MAXOPENCURSORS by default is 10. This number indicates the concurrent number of open cursors that the precompiler tries to keep cached. It specifies the initial size of the cursor cache. The limit of this parameter is determined by what you set OPEN_CURSORS to. Here is the formula:

MAXOPENCURSORS + 6 <= OPEN_CURSORS

6 is the overhead cursors Oracle needs.

Here is a calculation of the maximum number of cursors in use:

SQL statement cursors

PL/SQL parent cursors

PL/SQL child cursors

+6 cursors for overhead

-----------------------

sum of cursors in use.

[参考]

Max Open Cursor Limit

Overview of ORA-1000 Maximum Number of Cursors Exceeded

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值