Setting TTL parameters
Use the table ttl set subcommand to set TTL for the specified table.
General format of the command:
ydb [global options...] table ttl set [options...] <table path>
global options: Global parameters.options: Parameters of the subcommand.table path: The table path.
View a description of the TTL set command:
ydb table ttl set --help
Parameters of the subcommand
| Name | Description |
|---|---|
--column |
The name of the column that will be used to calculate the lifetime of the rows. The column must have the numeric or date and time type. In case of the numeric type, the value will be interpreted as the time elapsed since the beginning of the Unix epoch. Measurement units must be specified in the --unit parameter. |
--expire-after |
Additional time before deleting that must elapse after the lifetime of the row has expired. Specified in seconds. The default value is 0. |
--unit |
The value measurement units of the column specified in the --column parameter. It is mandatory if the column has the numeric type.Possible values:
|
--run-interval |
The interval for running the operation to delete rows with expired TTL. Specified in seconds. The minimum allowed interval is 15 minutes (900 seconds). The default value (3600) is a good starting point for working with a TTL-enabled table.When choosing --run-interval, balance the delay before expired data is physically removed against the extra load on the cluster. Too small an interval triggers deletion background tasks frequently and can noticeably increase CPU and I/O load, especially with large data volumes. Too large an interval, conversely, delays physical deletion of rows: expired data occupies disk space longer and may continue to participate in scans.Regardless of the --run-interval value, queries to the table may return rows with expired TTL. |
Examples
Note
The examples use the quickstart profile. To learn more, see Creating a profile to connect to a test database.
Set TTL for the series table
ydb -p quickstart table ttl set \
--column createtime \
--expire-after 3600 \
--run-interval 1200 \
series
Was the article helpful?
Previous