You can use a Lastpoint index to quickly retrieve data of the latest point in time in time series in a time series table. You can call the CreateTimeseriesLastpointIndex operation to create a Lastpoint index for a time series table. When you create a Lastpoint index, you must specify the names of the time series table and the Lastpoint index. You can also specify whether to include the existing data of the time series table in the Lastpoint index.
You can also create a Lastpoint index when you create a time series table. For more information, see Create a time series table.
Usage notes
Tablestore SDK for Go V1.7.15 or later supports the Lastpoint index feature. To use the Lastpoint index feature, make sure that you obtain Tablestore SDK for Go V1.7.15 or later.
After you create a Lastpoint index for a time series table, when data is written to the time series table, Tablestore automatically synchronizes data of the latest point in time in time series in the time series table to the Lastpoint index in asynchronous manner. In most cases, the synchronization latency is within milliseconds.
After data is synchronized to the Lastpoint index, the Lastpoint index contains the partition key (the
_#h
field) generated by Tablestore for the time series, the time series identifiers, and data of the latest point in time in the time series.You are not charged for creating a Lastpoint index. You are charged for the storage usage of Lastpoint indexes and when you read data from Lastpoint indexes. For more information, see Billable items of the TimeSeries model.
If you query or retrieve data in a Lastpoint index by executing SQL statements or using a search index, SQL query- or search index-related fees will be incurred according to the billing rules of the respective features. For more information, see Billable items of SQL query and Billable items of search indexes.
The total number of Lastpoint indexes and analytical stores that you create for a time series table cannot exceed 10.
Prerequisites
An instance for the TimeSeries model is created in a region that supports the Lastpoint index features. For more information, see Create an instance for the TimeSeries model.
A TimeseriesClient is initialized. For more information, see Initialize a Tablestore client.
Parameters
Parameter | Required | Description |
timeseriesTableName | Yes | The name of the time series table. |
lastpointIndexName | Yes | The name of the Lastpoint index. |
includeBaseData | No | Specifies whether to include the existing data of the time series table in the Lastpoint index. Type: Boolean. Valid values:
|
Examples
The following sample code provides an example on how to create a Lastpoint index named last_point_index for a time series table named timeseries_table. In this example, the Lastpoint index includes the existing data of the time series table.
func createTimeseriesLastpointIndex(client *tablestore.TimeseriesClient) {
request := tablestore.NewCreateTimeseriesLastpointIndexRequest("test_timeseries_table", "last_point_index", true)
_, err := client.CreateTimeseriesLastpointIndex(request)
if err != nil {
log.Fatal(err)
}
}
References
After you create a Lastpoint index, you can read data from the Lastpoint index by using the following methods:
Use the data read operations for data tables to read data. For more information, see Read data.
Create a search index for the Lastpoint index and use the query features of the search index to read data.
Create an SQL mapping table for the Lastpoint index and execute the SELECT statement to read data.
If you no longer want to use a Lastpoint index, you can delete it. For more information, see Delete a lastpoint index.