Undo retention in DBA

Undo retention

When automatic undo management is enabled, there is always a current undo retention period, which is the minimum amount of time that oracle database attempts to retain old undo information before overwriting it. Old (committed) undo information that is older than the current undo retention period is said to be expired. Old undo information with an age that is less than the current undo retention period is said to be unexpired.

Oracle database automatically tunes the undo retention period based on undo tablespace size and system activity. You can specify a minimum undo retention period (in seconds) by setting the undo_retention initialization parameter. The database makes its best effort to honor the specified minimum undo retention period, provided that the undo tablespace has space available for new transactions. When available space for new transactions becomes short, the database begins to overwrite expired undo. If the undo tablespace has no space for new transactions after all expired undo is overwritten, the database may begin overwriting unexpired undo information. If any of this overwritten undo information is required for consistent read in a current long-running query, the query could fail with the snapshottooold error message.

The following points explain the exact impact of the undo_retention parameter on undo retention:

The undo_retention parameter is ignored for a fixed size undo tablespace. The database may overwrite unexpired undo information when tablespace space becomes low.

For an undo tablespace with the autoextend option enabled, the database attempts to honor the minimum retention period specified by undo_retention. When space is low, instead of overwriting unexpired undo information, the tablespace auto-extends. If the maxsize clause is specified for an auto-extending undo tablespace, when the maximum size is reached, the database may begin to overwrite unexpired undo information.

Retention guarantee:

To guarantee the success of long-running queries or oracle flashback operations, you can enable retention guarantee. If retention guarantee is enabled, the specified minimum undo retention is guaranteed; the database never overwrites unexpired undo data even if it means that transactions fail due to lack of space in the undo tablespace. If retention guarantee is not enabled, the database can overwrite unexpired undo when space is low, thus lowering the undo retention for the system. This option is disabled by default.

Note:

You enable retention guarantee by specifying the retention guarantee clause for the undo tablespace when you create it with either the create database or create undo tablespace statement. Or, you can later specify this clause in an alter tablespace statement. You disable retention guarantee with the retention noguarantee clause.

You can use the dba_tablespaces view to determine the retention guarantee setting for the undo tablespace. A column named retention contains a value of guarantee, noguarantee, or not apply (used for tablespaces other than the undo tablespace).