You can call the CreateTimeseriesAnalyticalStore operation to create an analytical store for an existing time series table when you want to store time series data at a low cost and quickly query and analyze time series data.
Prerequisites
An instance for the TimeSeries model is created in a region that supports the analytical store feature. For more information, see Create an instance for the TimeSeries model.
A client is initialized. For more information, see Initialize a Tablestore client.
Parameters
Parameter | Description | |
timeseriesTableName | The name of the time series table. | |
analyticalStore | 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:
| |
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)
}
}