Oracle 参数 CURSOR_INVALIDATION 官方解释,作用,如何配置最优化建议
本站中文解释
(游标失效)
CURSOR_INVALIDATION参数定义了游标在执行DML或DDL时失效的级别,该参数有四个值:
1. IMMEDIATE:此值为默认值,只有当前游标标准在该语句之后执行才会失效。
2. SESSION:此值的范围比IMMEDIATE更大,表示游标失效只有在整个会话中最后一次使用此游标执行完毕后,才会失效。
3. DDL:此值指出有DDL活动时,游标将失效。
4. NONE:此值指出其他活动不会影响当前游标,只有当用户明确执行了commit或rollback时,才会失效。
正确设置方法:
要正确设置CURSOR_INVALIDATION,应根据用户的特定需求和会话的性能来确定要使用哪一个值。一般来说,在使用联机事务处理系统(OLTP)时,推荐使用IMMEDIATE或SESSION的值。如果在处理OLTP系统中的大批量任务时,应该将值设置为NONE,以提高性能。
官方英文解释
CURSOR_INVALIDATION
controls whether deferred cursor invalidation or immediate cursor invalidation is used for DDL statements by default.
Property | Description |
---|---|
Parameter type |
String |
Syntax |
|
Default value |
|
Modifiable |
|
Modifiable in a PDB |
Yes |
Basic |
No |
Oracle RAC |
Different instances can have different values. |
Deferred invalidation reduces the number of cursor invalidations and spreads the recompilation workload over time. Note that when the recompilation workload is spread over time, a cursor may run with a sub-optimal plan until it is recompiled, and may incur small execution-time overhead.
Prior to Oracle Database 12c Release 2 (12.2.0.1), immediate cursor invalidation was used.
This parameter provides system or session level default for the DEFERRED
or IMMEDIATE
option for the INVALIDATION
clause in DDL statements.
When this parameter is set to DEFERRED
, an application can take advantage of reduced cursor invalidation without making any other application changes.
When this parameter is set to IMMEDIATE
, the application will experience the same cursor invalidation behavior as in Oracle Database 12c Release 1 (12.1).