All Products
Search
Document Center

Tablestore:Update the TTL of data in a time series analytical store

Last Updated:Apr 22, 2025

If you want to delete historical data in an analytical store or extend the retention period of data in an analytical store, you can call the UpdateTimeseriesAnalyticalStore operation to update the time to live (TTL) configuration of the analytical store. After you update the TTL configuration of the analytical store, Tablestore automatically deletes data whose retention period exceeds the TTL value from the analytical store in an asynchronous manner.

Prerequisites

Usage notes

  • The synchronization option of an analytical store cannot be updated.

  • The minimum TTL of an analytical store is 30 days (2,592,000 seconds).

  • When you create an analytical store, if the TTL is not set to -1, Tablestore automatically deletes data whose retention period exceeds the TTL value from the analytical store in an asynchronous manner. You can also modify the TTL of the analytical store by calling the UpdateTimeseriesAnalyticalStore operation.

    Data whose retention period exceeds the TTL value is invalid data. Even if the system has not deleted the invalid data, users can no longer read the data.

    • When you decrease the TTL value, data in the analytical store may expire, and the system will delete the corresponding expired data in an asynchronous manner.

    • When you increase the TTL value, if the system has not deleted the data whose retention period exceeds the old TTL value and the retention period of the data is less than or equal to the new TTL value, the data can still be read.

Parameters

Parameter

Description

timeseriesTableName

The name of the time series table.

analyticalStore

analyticalStoreName

The name of the analytical store.

timeToLive

The retention period of data in the analytical store, in seconds. Valid values: -1 (data never expires) or a positive int32 integer greater than or equal to 2592000 (30 days).

If you want the data in the analytical store to never expire, you can set timeToLive to -1.

Example

The following sample code provides an example on how to update the TTL of data in an analytical store named test_analytical_store created for the test_timeseries_table time series table to 30 days (2,592,000 seconds):

public void updateAnalyticalStore(TimeseriesClient client) {
    //Specify the name of the analytical store.
    TimeseriesAnalyticalStore store = new TimeseriesAnalyticalStore("test_analytical_store");
    //Update the TTL of the analytical store to 2,592,000 seconds.
    store.setTimeToLive(2592000);
    //Specify the name of the time series table.
    UpdateTimeseriesAnalyticalStoreRequest request = new UpdateTimeseriesAnalyticalStoreRequest("test_timeseries_table");
    request.setAnalyticStore(store);
    client.updateTimeseriesAnalyticalStore(request);
}