oracle收集统计信息,游标失效时间

简介: Dbms_stats Invalidates Cursors in Auto_invalidate mode

1,控制方法和命令:

DBMS_STATS Constants

Name Type Description

ADD_GLOBAL_PREFS

NUMBER

Copies global preferences

AUTO_CASCADE

BOOLEAN

Lets Oracle decide whether to collect statistics for indexes or not

AUTO_DEGREE

NUMBER

Lets Oracle select the degree of parallelism based on size of the object, number of CPUs and initialization parameters

AUTO_INVALIDATE

BOOLEAN

Lets Oracle decide when to invalidate dependent cursors

AUTO_SAMPLE_SIZE

NUMBER

Indicates that auto-sample size algorithms should be used

PURGE_ALL

TIMESTAMP WITH TIME ZONE

A flag that can be passed to the PURGE_STATS Procedure and unconditionally deletes all the history statistics. The deletion uses TRUNCATE statements on the various dictionary statistics tables holding the history of statistics.

RECLAIM_SYNOPSIS

TIMESTAMP WITH TIME ZONE

A constant used for reclaiming synopsis table space.


2,失效时间

  • when DBMS_STATS modifies statistics for an object, all current cached cursors depending on this object are marked for rolling invalidation. Let's call this time T0.
  • the next time a session executes a cursor marked for rolling invalidation, it sets a timestamp. This timestamp can take a (pseudo-)random value up to _optimizer_invalidation_period sec from the time of this parse. The reason it does this is to randomly distribute the actual invalidation so as to avoid multiple parses occurring at the same time as much as possible.The default for this parameter is 18000 sec i.e. 5 hours. Let's call the time of this parse T1 and the timestamp value Tmax. On this (first) execution and parse we reuse the existing cursor i.e. we do not hard-parse and do not use the modified statistics to generate a new plan (it is a soft parse.)
  • on every subsequent execution and  parse of this cursor (which is now marked for rolling invalidation and timestamped) we check whether the current time T2 exceeds the timestamp Tmax. If not, we reuse the existing cursor again, as happened on the first (soft) parse at time T1. If Tmax has been exceeded, we invalidate the cached cursor and create a new version of it (a new child cursor) which uses the new statistics of the object to generate its execution plan. The new child is marked ROLL_INVALID_MISMATCH in V$SQL_SHARED_CURSOR to explain why we could not share the previous child.
  • the next time a session executes a cursor marked for rolling invalidation, it sets a timestamp. This timestamp can take a (pseudo-)random value up to _optimizer_invalidation_period sec from the time of this parse. The reason it does this is to randomly distribute the actual invalidation so as to avoid multiple parses occurring at the same time as much as possible.The default for this parameter is 18000 sec i.e. 5 hours. Let's call the time of this parse T1 and the timestamp value Tmax. On this (first) execution and parse we reuse the existing cursor i.e. we do not hard-parse and do not use the modified statistics to generate a new plan (it is a soft parse.)



Resolving Issues Where Dbms_stats Invalidates Cursors in Auto_invalidate mode (Doc ID 1477717.1)

Rolling Cursor Invalidations with DBMS_STATS.AUTO_INVALIDATE (Doc ID 557661.1)
























相关文章
|
2月前
|
SQL Oracle 关系型数据库
Oracle的PL/SQL隐式游标:数据的“自动导游”与“轻松之旅”
【4月更文挑战第19天】Oracle PL/SQL中的隐式游标是自动管理的数据导航工具,简化编程工作,尤其适用于简单查询和DML操作。它自动处理数据访问,提供高效、简洁的代码,但不适用于复杂场景。显式游标在需要精细控制时更有优势。了解并适时使用隐式游标,能提升数据处理效率,让开发更加轻松。
|
2月前
struts+hibernate+oracle+easyui实现lazyout组件的简单案例——Dept实体类和对应的配置信息
struts+hibernate+oracle+easyui实现lazyout组件的简单案例——Dept实体类和对应的配置信息
|
6天前
|
SQL Oracle 关系型数据库
Oracle游标的使用和优化技巧
Oracle游标的使用和优化技巧
|
2天前
|
SQL 存储 Oracle
Oracle数据库中游标的工作原理与优化方法
Oracle数据库中游标的工作原理与优化方法
|
4天前
|
SQL Oracle 关系型数据库
Oracle游标的使用和优化技巧
Oracle游标的使用和优化技巧
|
7天前
|
SQL Oracle 关系型数据库
Oracle游标的定义与使用
Oracle游标的定义与使用
|
7天前
|
SQL Oracle 关系型数据库
Oracle游标的定义与使用技巧
Oracle游标的定义与使用技巧
|
2天前
|
Oracle 关系型数据库
oracle收集统计信息,游标失效时间
Dbms_stats Invalidates Cursors in Auto_invalidate mode
17 0
|
4天前
|
SQL 存储 Oracle
Oracle数据库中游标的工作原理与优化方法
Oracle数据库中游标的工作原理与优化方法
|
12天前
|
SQL Oracle 关系型数据库
Oracle中的游标用法总结
Oracle中的游标用法总结