All Products
Search
Document Center

Hologres:Time Travel

Last Updated:Oct 29, 2025

Hologres supports Time Travel in V4.0 and later versions. This feature records a history of data changes, such as INSERT, DELETE, UPDATE, and INSERT OVERWRITE, letting you query data as it existed at any point in time within a specified retention period. Use Time Travel to analyze data changes over time or to recover accidentally updated or deleted data, helping prevent business loss.

Limitations

  • This feature is available for Hologres instances V4.0 and later. If your instance is an earlier version, see Upgrade an instance.

  • Time Travel is supported only for internal tables and Dynamic Tables.

    Note

    For information about Time Travel queries on foreign/external tables, see Access a Paimon catalog in DLF.

Usage

Set Time Travel

  • Syntax:

    To enable Time Travel, set the following two properties when you create a table:

    CREATE TABLE <table_name> (...)
    WITH (
        enable_mvcc = 'true|false',
        mvcc_gc_ttl_seconds = '<num>'
    );
  • Notes

    • Set these parameters when creating a table. They cannot be configured on an existing one.

    • Enabling Time Travel stores multiple data versions, which increases storage usage.

    • Enabling Time Travel can slightly degrade query performance.

  • Parameters

    Parameter

    Description

    enable_mvcc

    Specifies whether to enable Time Travel. Valid values:

    • true: Enables Time Travel. This setting cannot be disabled once enabled.

    • false (default): Disables Time Travel.

    mvcc_gc_ttl_seconds

    The Time to Live (TTL) for each data version, in seconds (s).

    • The default value is 86400, which is one day (24 * 3600 s).

    • The minimum value is 0. This does not disable Time Travel. Instead, it means that data versions are recycled after 0 seconds and cannot be queried.

    Note

    Hologres periodically deletes expired data versions. Consequently, queries for data beyond the specified TTL will fail. An example error is: Tablexxx only supports time traveling between xxx and xxx;.

Query data using Time Travel

After you enable Time Travel, query data from a specific point in time within the TTL period using the FOR TIMESTAMP AS OF clause. The syntax is as follows:

SELECT * FROM {table_name} FOR TIMESTAMP AS OF (now() - interval '1 hour');
SELECT * FROM {table_name} FOR TIMESTAMP AS OF '2025-08-05 11:18:50+08';
SELECT * FROM {table_name} FOR TIMESTAMP AS OF 1754374966;

Modify Time Travel TTL

Modify the TTL for Time Travel. The syntax is as follows:

ALTER TABLE {table_name} SET (mvcc_gc_ttl_seconds =<num>);

Modifying the TTL has the following effects:

  • When you decrease the TTL: Hologres deletes expired data versions in the background under the new TTL. Queries for data beyond the new TTL will fail.

  • When you increase the TTL: Data versions deleted under the previous, shorter TTL cannot be recovered. To avoid potential data gaps and inaccurate queries, do not increase the TTL in a production environment.

Examples

  1. Create a table and enable Time Travel.

    BEGIN;
    CREATE TABLE test1 (
        a int NOT NULL PRIMARY KEY,
        b int,
        c int
    )
    WITH (
        enable_mvcc = TRUE,
        mvcc_gc_ttl_seconds = 864000
    );
    COMMIT;
    
    -- Insert data
    INSERT INTO test1 VALUES (1, 2, 3);
  2. Query data using Time Travel.

    SELECT * FROM test1 FOR TIMESTAMP AS OF now();

    The following result is returned.

    a	b	c
    ------
    1	2	3
    
  3. Update the table and query it using Time Travel.

    INSERT INTO test1 (a, b, c) VALUES (1, 4, 5)
    ON CONFLICT (a)
    DO UPDATE SET b = EXCLUDED.b;
    
    SELECT * FROM test1 FOR TIMESTAMP AS OF (now() - interval '1 minute');

    The following result is returned.

    a	b	c
    ------
    1	4	5