Open Cursor Reference

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

OPEN_CURSORS

Property Description
Parameter type Integer
Default value 50
Modifiable ALTER SYSTEM
Range of values 0 to 65535
Basic Yes

OPEN_CURSORS specifies the maximum number of open cursors (handles to private


SQL areas) a session can have at once. You can use this parameter to prevent a
session from opening an excessive number of cursors.

It is important to set the value of OPEN_CURSORS high enough to prevent your


application from running out of open cursors. The number will vary from one
application to another. Assuming that a session does not open the number of
cursors specified by OPEN_CURSORS, there is no added overhead to setting this
value higher than actually needed.

The open_cursors parameter is a governor, a block to prevent runaway tasks from


consuming too much library cache RAM.

Any session may execute many SQL statements and the open_cursors parameter
governs the total number of open cursors for any given session.

For example, if you set open_cursors=100, Oracle will be allowed to allocate up to


100 cursor slots in the library cache. Because the slots are only allocated as they
are requested, there is no added overhead to setting this value higher than actually
needed.

The starting value is set by Oracle at instance creation time.

Just like the sessions and processes parameters, your application usage determines
the value for open_cursors.

If you set open_cursors value too high, you risk having a task abort with the ORA-
01000 error:

ORA-01000 maximum open cursors exceeded

Whenever you get an ORA-01000 error you need to determine if the session has a
bug or whether the cursor requests are legitimate. You can change the
open_cursors parameter dynamically while the database is running using an alter
system statement:
alter system set open_cursors = 400 scope=both;

You can monitor your high water mark for open cursors with a query like this:

select
max(a.value) as hwm_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;
In sum, the open_cursors parameter default value is usually enough for any
application, and it can be increased as-needed, depending upon your application.

You might also like