Oracle Flashback Best Practices

Oracle AI Database Flashback Technologies is a unique and rich set of data recovery solutions that let the database reverse human errors by selectively and efficiently undoing the effects of a mistake.

Before Flashback was introduced to Oracle AI Database, it might have taken minutes to damage a database but hours to recover it. With Flashback, correcting an error takes about as long as it took to make it. In addition, the time required to recover from this error is not dependent on the database size, which is a capability unique to Oracle AI Database.

Flashback supports database recovery at all levels, including the row, transaction, table, and the entire database. Flashback provides an ever-growing set of features to view and rewind data back and forth in time, and address several critical high availability and disaster recovery use cases. The list of features and use cases, as well as some key examples, can be found in Oracle Flashback Technology.

The Flashback features give you the capability to query historical data, perform change analysis, and perform the self-service repair to recover from logical corruptions while the database is online. With Oracle Flashback Technology, you can indeed undo the past.

Oracle Flashback Performance Observations

After adopting the configuration and operational best practices and applying recommended patches, Oracle has observed the following performance observations when Flashback Database is enabled on the primary or standby databases.

The following lists describe the critical flashback milestones and key performance improvements across different Oracle Database software releases:

Oracle Database 12c Release 2 (12.2)

Oracle Database 19c

Oracle Database 21c

Oracle Flashback Configuration Best Practices

The following are Oracle MAA best practices for configuring Flashback technologies in Oracle AI Database.

Setting DB_FLASHBACK_RETENTION_TARGET

Set the DB_FLASHBACK_RETENTION_TARGET initialization parameter to the largest value prescribed by any of the following conditions that apply:

Sizing the Fast Recovery Area

Flashback Database uses its own logging mechanism, creating flashback logs and storing them in the Fast Recovery Area (FRA). Ensure that the FRA has allocated sufficient space to accommodate the flashback logs for the target retention size and for peak batch rates. Sizing the FRA is described in detail in the Oracle Backup and Recovery documentation, but generally the volume of flashback log generation is similar in magnitude to redo log generation. Use the following conservative formula and approach:

Target FRA = Current FRA + DB_FLASHBACK_RETENTION_TARGET x 60 x Peak Redo Rate (MB/sec)

Example:

An additional method to determine FRA sizing is to enable Flashback Database and allow the database applications to run for a short period (2-3 hours), and then query V$FLASHBACK_DATABASE_STAT.ESTIMATED_FLASHBACK_SIZE.

Note that the DB_FLASHBACK_RETENTION_TARGET is a target, and there is no guarantee that you can flash back the database that far. The oldest flashback logs may be deleted if there is space pressure in the FRA where the flashback logs are stored. See Maintaining the Fast Recovery Area in Oracle AI Database Backup and Recovery User’s Guide for a detailed explanation of the FRA deletion rules. You must use guaranteed restore points (GRP) to guarantee a flashback point-in-time. The required flashback logs will never be recycled or purged with GRP until GRP is dropped. The database can stop responding if there is a GRP but there is insufficient space, so you must allocate more space in the FRA depending on the intended duration of the GRP.

Configuring sufficient I/O bandwidth for Fast Recovery Area

Insufficient I/O bandwidth with Flashback Database on is usually indicated by a high occurrence of the “FLASHBACK BUF FREE BY RVWR” wait event in an Automatic Workload Repository (AWR) report for OLTP workloads and “FLASHBACK LOG FILE WRITE” latency > 30 ms for large insert operations.

In general, flashback I/Os are 1 MB in size. The overall write throughput would be similar to the redo generation rate if database force logging were enabled, or identical to your load rate for direct load operations. For simplicity, configure one large shared storage GRID and configure DATA on the outer portion of the disks or LUNS and RECO (FRA) on the inner amount of the disks or LUNS. This is done automatically for Exadata systems.

Setting LOG_BUFFER

To give Flashback Database more buffer space in memory, set the initialization parameter LOG_BUFFER=256MB or higher, depending on operating system limits.

Oracle Flashback Operational Best Practices

The following are Oracle MAA recommended operational best practices for Flashback Database.

Oracle Flashback Performance Tuning for Specific Application Use Cases

Performance Tuning for OLTP Workloads

The “flashback buf free by RVWR” wait event only occurs when Flashback Database is enabled. A session waits for the recovery writer (RVWR) to write flashback data to the flashback logs on disk because the buffers are full. The session may need to wait until RVWR can free up the buffers.

Suppose this event becomes one of the top wait events for the database. In that case, it is typically because the file system or storage system for the Fast Recovery Area (FRA) has insufficient I/O bandwidth to accommodate additional I/O from the Flashback writes. Refer to the Flashback Database section in the Oracle AI Database Backup and Recovery User’s Guide for tuning considerations and evaluate the corresponding I/O and storage statistics.

Table 1 Top 5 Timed Foreground Events

Event Waits Times Average wait (ms) % database time Wait class
write complete waits 1,842 23,938 12995 33.68 Configuration
flashback buf free by RVWR 53,916 20,350 377 28.63 Configuration
cell single block physical read 3,029,626 16,348 5 23.00 User I/O
buffer busy waits 6,248 5,513 882 7.76 Concurrency
DB CPU   1,757   2.47  

Performance Tuning for Direct Path Operations

Look at the “flashback log write bytes” and “physical write bytes” system statistics found in v$sysstat, in your AWR reports, or Oracle Enterprise Manager.

If (flashback log write bytes) / (physical write bytes) < 5%, then Flashback is not impacting your performance.

Otherwise, evaluate any operational changes or bug fixes that will allow you to use the Flashback block new optimization feature (refer to performance observation section above). Furthermore, ignore the “flashback log file sync” wait event, even if it’s one of the top wait events.

Example of block new optimization in effect

In this example:

The result of (flashback log write bytes) / (physical write bytes) = 0.0066 < 5%, implies that there’s only a fraction of flashback data compared to the physical writes within this interval where there are direct load operations. Even in this case, the “flashback log file sync” wait event was the 2nd highest wait event in the database, as shown in the following table.

Table 2 Top 5 Timed Foreground

Event Waits Times Average wait (ms) % database time Wait class
direct path write 136,553 7,875 58 39.12 User I/O
flashback log file sync 91,566 5,887 64 29.25 User I/O
DB CPU   3,092   15.36  
log buffer space 20,545 1,737 85 8.63 Configuration
gc buffer busy release 1,277 487 382 2.42 Cluster

Example of block new optimization not in effect

In this example:

The result of (flashback log write bytes) / (physical write bytes) = 100% > 5%, implies that in this case all direct writes also result in flashback log writes. Listed here are the top wait events for this case.

Table 3 Top 5 Timed Foreground

Event Waits Times Average wait (ms) % database time Wait class
flashback log file sync 170,088 22,385 132 52.04 User I/O
direct path write 278,185 8,284 30 19.26 User I/O
flashback buf free by RVWR 38,396 5,048 131 11.74 Configuration
direct path read 220,618 4,242 19 9.86 User I/O
DB CPU   2,788   6.48  

Performance Tuning for Conventional Load Operations

The following examples illustrate two conventional loads, one that uses block new optimization and one that does not.

Example of block new optimization not in effect

The example below does not use the block new optimization because of a truncate just before loading the table. The wait events for a conventional load without block new optimization show a fairly large amount of total wait time spent in “flashback log file sync”. This is because of time needed to read them before the image of the block into the buffer cache and well as writing the block to the flashback log.

Table 4 Top 5 Timed Foreground Events

Event Waits Times Average wait (ms) % database time Wait class
flashback log file sync 235,187 13,728 58 30.82 User I/O
direct path write 558,037 10,818 19 24.29 User I/O
direct path read 459,076 8,419 18 18.90 User I/O
DB CPU   6,171   13.85  
flashback buf free by RVWR 79,463 4,268 54 9.58 Configuration

Looking at the instance statistics below you can see very little increase in the statistics that track block new optimizations.

Statistic Total Per second Per transaction
flashback cache read optimizations for block new 62 0.06 1.13
flashback direct read optimizations for block new 8 0.01 0.15
flashback log write bytes 177,533,280,256 177,245,433.67 3,227,877,822.84
flashback log writes 18,917 18.89 343.95

If the “flashback cache read optimizations for block new” is much smaller than “flashback log writes” then the block new optimization does not have an effect.

The best tuning recommendation for the above load operation would be to increase I/O bandwidth or, perhaps better, change the manner in which the load is performed so that it can take advantage of block new optimizations. You can also wait until you are outside the flashback retention target, or remove the object from recycle bin if it was dropped.

Example of block new optimization not effect

The wait events for a conventional load with block new optimization show a relatively small amount of total time spent in “flashback log file sync” compared to other database waits, as shown here.

Table 5 Top 5 Timed Foreground Events

Event Waits Times Average wait (ms) % database time Wait class
direct path write 284,115 8,977 32 34.20 User I/O
DB CPU   6,284   23.94  
log buffer space 128,879 5,081 39 19.36 Configuration
flashback log file sync 139,546 3,178 23 12.11 User I/O
latch: redo allocation 95,887 1,511 16 5.76 Other

Looking at the instance statistics you can see that the statistics that track block new operations have significantly increased during the load.

Statistic Total Per second Per transaction
flashback cache read optimizations for block new 329 0.53 9.68
flashback direct read optimizations for block new 698,410 1,116.43 20,541.47
flashback log write bytes 1,197,514,752 1,914,271.66 35,221,022.12
flashback log writes 18,951 30.29 557.38