All Products
Search
Document Center

Hologres:Time Travel

Last Updated:Mar 06, 2026

Hologres supports the Time Travel feature starting from V4.0. When you enable this feature, it records historical versions of every data change, such as INSERT, DELETE, UPDATE, and INSERT OVERWRITE. You can query historical data at any point in time within a specified range, including data that has been updated or deleted. Time Travel lets you analyze data usage within a specified period, recover accidentally deleted data or data from before an update, and mitigate business loss.

Limits

  • Only Hologres V4.0 and later versions support this feature. If your instance runs a version earlier than Hologres V4.0, see Instance Upgrade.

  • Only Hologres internal tables and Dynamic Tables support Time Travel.

    Note

    For Time Travel queries on foreign tables, see Access Paimon data using a DLF Catalog.

Usage Instructions

Set Time Travel

  • Syntax:

    Time Travel is a table-level property. You can set the following two properties when creating a table:

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

    • Existing tables do not support setting these parameters. You must set them when creating a new table.

    • When you enable Time Travel, the table stores multiple data versions, which increases storage consumption.

    • When you enable Time Travel, queries might experience some performance loss.

  • Parameter description

    Parameter Name

    Description

    enable_mvcc

    Enable the Time Travel feature. Values are as follows:

    • true: Enable. After enabling Time Travel, you cannot disable it.

    • false (default): Disable.

    mvcc_gc_ttl_seconds

    After enabling Time Travel, this is the duration (in seconds) for which each data version is retained.

    • The default value is 1 day = 24 × 3600 s = 86400 s.

    • The minimum value is 0. This does not mean disabling Time Travel. Instead, it means data versions are reclaimed after 0 s and cannot be queried.

    Note

    When you query beyond the Time Travel retention TTL range, the system periodically deletes retained version data in the background, and the query will report an error. Example error: Tablexxx only supports time traveling between xxx and xxx;.

Query Data Using Time Travel

After enabling Time Travel, you can use the FOR TIMESTAMP AS OF syntax to query data at a specific point in time within the TTL range. 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

You can modify the Time Travel TTL as needed. The syntax is as follows:

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

The behavior of modifying TTL is as follows:

  • When you change the TTL from a larger value to a smaller value, the system deletes expired version data in the background based on the new TTL value. Queries for data versions exceeding the TTL will report an error.

  • When you change the TTL from a smaller value to a larger value, this can lead to inaccurate queries because previously deleted version records within the TTL range cannot be recovered. Therefore, avoid changing the TTL from a smaller value to a larger value in production.

Usage Examples

  1. You can 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. You can query data using Time Travel.

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

    The returned result is as follows.

    a	b	c
    ------
    1	2	3
    
  3. You can update the table and query 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 returned result is as follows.

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