All Products
Search
Document Center

PolarDB:Flashback Table

Last Updated:Feb 28, 2026

The flashback table feature periodically records data snapshots to flashback logs and saves transaction information to the fast recovery area. You can use the flashback table feature to restore data at a point in time to a new table. If an accidental operation causes a data error, you can use flashback logs to quickly identify the error time and then restore the table data to a point before the error time.

Prerequisites

Before you can use the flashback table feature, enable both of the following parameters in the Parameters page of your PolarDB cluster:

ParameterSet to
polar_enable_flashback_logON
polar_enable_fast_recovery_areaON

These parameters enable flashback logs and the fast recovery area, respectively. Both are required for the flashback table feature to function.

Limitations

Supported table types

The flashback table feature supports only ordinary (regular) tables. The following database objects cannot be restored:

  • Indexes
  • TOAST tables
  • Materialized views
  • Partitioned tables
  • Partitions of a partitioned table (child tables)
  • System tables
  • External tables
  • Tables that contain child TOAST tables

DDL restrictions

You cannot flash back a table if any of the following DDL operations were performed on it between the target timestamp and the current time:

  • DROP TABLE
  • ALTER TABLE SET WITH OIDS
  • ALTER TABLE SET WITHOUT OIDS
  • TRUNCATE TABLE
  • Modifying a column type where the source and target types cannot be implicitly converted, unless a USING clause is specified for explicit type conversion.
  • Setting the table to UNLOGGED or LOGGED.
  • Adding an identity column.
  • Adding a column with a restricted data type.
  • Adding a column whose default value expression contains volatile functions.

Parameters

PolarDB provides a set of parameters for fine-grained control over flashback table behavior. Modify all required parameters at the same time and restart the cluster during off-peak hours.

Core parameters

These parameters control the fundamental behavior of the flashback table feature.

ParameterDescriptionValid valuesDefaultUnit
polar_enable_flashback_logEnables or disables flashback logs. The flashback table feature requires this parameter to be set to ON.ON, OFF----
polar_enable_fast_recovery_areaEnables or disables the fast recovery area. The flashback table feature requires this parameter to be set to ON.ON, OFF----
polar_fast_recovery_area_rotationThe retention period for transaction information in the fast recovery area. A larger value increases disk space consumption.1 -- 14400180Minutes
polar_flashback_log_keep_segmentsThe number of flashback log files to retain. Flashback log files are reusable, and each file is 256 MB.3 -- 21474836478Segments

Flashback point parameters

These parameters control how frequently PolarDB creates flashback points in time, which determine the granularity of available restore targets.

ParameterDescriptionValid valuesDefaultUnit
polar_flashback_point_segmentsThe minimum number of WAL between two consecutive flashback points in time. Each WAL segment is 1 GB. We recommend setting this to a multiple of the max_wal_size value.1 -- 214748364716Segments
polar_flashback_point_timeoutThe minimum time interval between two consecutive flashback points in time. We recommend setting this to a multiple of the checkpoint_timeout value.1 -- 86400300Seconds

Memory parameters

These parameters configure the shared memory allocation for flashback log structures.

ParameterDescriptionValid valuesDefaultUnit
polar_flashback_log_buffersThe shared memory size allocated to flashback log buffers.4 -- 2621442048KB
polar_flashback_logindex_mem_sizeThe shared memory size allocated to flashback log indexes.3 -- 107374182364MB
polar_flashback_logindex_bloom_blocksThe number of Bloom filter pages for flashback log indexes. Each data page is 8 KB.8 -- 1073741823512Blocks

Performance parameters

These parameters tune the parallelism and background process behavior for flashback operations.

ParameterDescriptionValid valuesDefaultUnit
polar_workers_per_flashback_tableThe number of parallel workers for a flashback table operation. Set to 0 to disable parallel flashback. Increase this value for large tables to reduce flashback time.0 -- 10245Workers
polar_flashback_log_insert_locksThe number of locks used for concurrent flashback log insertion.1 -- 21474836478Locks
polar_flashback_log_bgwrite_delayThe interval at which the bgwriter process writes flashback logs to disk.1 -- 10000100ms
polar_flashback_log_flush_max_sizeThe maximum log size that the bgwriter process can flush to disk in a single cycle. Set to 0 for unlimited.0 -- 20971525120KB
polar_flashback_log_insert_list_delayThe interval at which the bginserter process (a PolarDB-specific background process that manages flashback log insertion) operates.1 -- 1000010ms

Syntax

FLASHBACK TABLE [ schema. ]table TO TIMESTAMP expr;
Table 1. Parameters
ParameterDescription
[ schema. ]tableThe name of the table to flash back. Optionally specify the schema.
exprA timestamp expression representing the point in time to restore the table to.

Example

The following example demonstrates a complete flashback table workflow: creating a table, inserting data, verifying the baseline, deleting data, performing a flashback, and verifying the restored data.

Step 1: Create a table and insert data

Create a test table and populate it with 10,000 rows.

CREATE TABLE test(id int);
INSERT INTO test select * FROM generate_series(1, 10000);

Step 2: Verify the baseline data

Query the row count and sum to establish a baseline.

SELECT count(1) FROM test;
 count
-------
  10000
(1 row)
SELECT sum(id) FROM test;
   sum
----------
  50005000
(1 row)

Step 3: Simulate an accidental deletion

Wait 10 seconds and then delete all rows from the table.

SELECT pg_sleep(10);
DELETE FROM test;

Verify that the table is now empty.

SELECT * FROM test;
 id
----
(0 rows)

Step 4: Perform the flashback

Restore the table data to its state 10 seconds ago.

FLASHBACK TABLE test TO TIMESTAMP now() - interval'10s';

PolarDB returns a NOTICE message indicating the name of the new table:

NOTICE:  Flashback the relation test to new relation polar_flashback_65566, please check the data
FLASHBACK TABLE

Step 5: Verify the restored data

Query the new table to confirm that the data has been restored correctly.

SELECT count(1) FROM polar_flashback_65566;
 count
-------
  10000
(1 row)
SELECT sum(id) FROM polar_flashback_65566;
   sum
----------
  50005000
(1 row)

The row count and sum match the baseline values from Step 2, confirming that the data has been fully restored.

After the flashback operation completes, you can query the data of the new table and compare it with the original table based on the NOTICE information. The missing data can be inserted back into the original table.

Usage notes

  • Resource overhead: Enabling flashback logs and the fast recovery area increases shared memory and disk space consumption and causes some performance overhead. Assess these impacts before enabling the feature in production.
  • Performance jitter during flashback: When a flashback table operation runs, table-related pages are swapped in and out of the shared memory pool. This may cause jitter in the access performance of other databases. We recommend performing flashback operations and restarting the cluster during off-peak hours.
  • Parameter changes: We recommend modifying all required parameters at one time and restarting the cluster during off-peak hours.