All Products
Search
Document Center

Tablestore:Create an analytical store

Last Updated:Sep 21, 2026

You can call the CreateTimeseriesAnalyticalStore operation to create an analytical store for an existing time series table to store and analyze time series data at low costs.

Prerequisites

Parameters

Parameter

Description

timeseriesTableName

The name of the time series table.

analyticalStore

The configuration of the analytical store, which includes the following sub-parameters.

  • analyticalStoreName: the name of the analytical store.

  • timeToLive: The time to live (TTL) of data in the analytical store. Unit: seconds. Valid values: -1 (data never expires) or a positive integer that is greater than or equal to 2592000 (30 days).

    If you want the data in the analytical store to never expire, you can set this parameter to -1. You can modify this parameter by calling the UpdateTimeseriesAnalyticalStore operation.

  • syncOption: The synchronization option of the analytical store. Valid values:

    • SYNC_TYPE_FULL: All data is synchronized to the analytical store.

    • SYNC_TYPE_INCR: Incremental data is synchronized to the analytical store.

Example

The following sample code provides an example on how to create an analytical store for the test_timeseries_table time series table. The analytical store is named test_analytical_store, with a TTL of 30 days (2592000 seconds), and the synchronization option set to SYNC_TYPE_INCR.

func CreateTimeseriesAnalyticalStore(client *tablestore.TimeseriesClient) {
    //Specify the name of the analytical store.
    analyticalStore := tablestore.NewTimeseriesAnalyticalStore("test_analytical_store")
    //Specify the TTL of the analytical store in seconds.
    analyticalStore.SetTimeToLive(2592000)
    //Specify the mode in which the data in the time series table is synchronized to the analytical store.
    analyticalStore.SetSyncOption(tablestore.SYNC_TYPE_INCR)
    //Specify the name of the time series table.
    request := tablestore.NewCreateTimeseriesAnalyticalStoreRequest("test_timeseries_table", analyticalStore)
    _, err := client.CreateTimeseriesAnalyticalStore(request)
    if err != nil {
         log.Fatal(err)
    }
}