The time to live (TTL) is an attribute of a search index that specifies the data retention period. Tablestore automatically deletes data that exceeds its retention period to reduce storage usage and lower storage costs.
Usage notes
To use the lifecycle management feature, you must disable the UpdateRow write operation for the data table.
-
This requirement prevents data inconsistency between the data table and the search index.
A data table's TTL is applied per attribute column, but a search index's TTL is applied to the entire row. If you use an UpdateRow operation, Tablestore might delete some columns from the data table while the corresponding row remains in the search index, causing them to become out of sync.
If you need to update data, use the PutRow operation to overwrite the entire row instead.
-
The TTL for a search index, specified in seconds, can be -1 or a positive 32-bit integer. A value of -1 means the data is stored permanently. The maximum value is approximately 68 years.
-
The TTL of a search index is independent of the data table's TTL. The TTL value of the search index must be less than or equal to the TTL value of the data table. When decreasing both TTLs, reduce the search index TTL first, and then reduce the data table TTL.
-
Tablestore automatically cleans up expired data from search indexes daily. You can still query data that has expired until it is removed during this cleanup process.
-
After you update the TTL for a data table and a search index, Tablestore removes any newly expired data during the next cleanup cycle.
Procedure
You can set the time to live (TTL) for a search index by using the console or an SDK. The UpdateRow operation must remain disabled on the data table to use this feature.