Skip to content

Commit

Permalink
ttl: updated ttl TTL_JOB_INTERVAL description
Browse files Browse the repository at this point in the history
  • Loading branch information
lcwangchao committed Dec 4, 2024
1 parent 4a5c722 commit 05248d4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions time-to-live.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,17 @@ CREATE TABLE orders (

## TTL job

For each table with a TTL attribute, TiDB internally schedules a background job to clean up expired data. You can customize the execution period of these jobs by setting the `TTL_JOB_INTERVAL` attribute for the table. The following example sets the background cleanup jobs for the table `orders` to run once every 24 hours:
For each table with a TTL attribute, TiDB internally schedules a background job to clean up expired data. You can customize the execution period of these jobs by setting the `TTL_JOB_INTERVAL` attribute for the table. The following example sets the background cleanup jobs for the table `orders` to run once every 48 hours:

```sql
ALTER TABLE orders TTL_JOB_INTERVAL = '24h';
ALTER TABLE orders TTL_JOB_INTERVAL = '48h';
```

`TTL_JOB_INTERVAL` is set to `1h` by default.
`TTL_JOB_INTERVAL` is set to `24h` by default (`1h` in v8.5 and the earlier version).

When executing a TTL job, TiDB will split the table into up to 64 tasks, with the Region being the smallest unit. These tasks will be executed distributedly. You can limit the number of concurrent TTL tasks across the entire cluster by setting the system variable [`tidb_ttl_running_tasks`](/system-variables.md#tidb_ttl_running_tasks-new-in-v700). However, not all TTL jobs for all kinds of tables can be split into tasks. For more details on which kinds of tables' TTL jobs cannot be split into tasks, refer to the [Limitations](#limitations) section.
When executing a TTL job, TiDB will split the table into some tasks, with the Region being the smallest unit. These tasks will be executed distributedly. Typically, the maximum number of tasks for a single table is 64. But for larger clusters, such as those with more than 64 TiKV instances, the maximum number of tasks that a single table can be split into is equal to the number of TiKV instances. However, not all TTL jobs for all kinds of tables can be split into tasks. For more details on which kinds of tables' TTL jobs cannot be split into tasks, refer to the [Limitations](#limitations) section.
TiDB also limits the number of concurrent TTL tasks at the cluster level. You can set the system variable [`tidb_ttl_running_tasks`](/system-variables.md#tidb_ttl_running_tasks-new-in-v700) to change this concurrency.
To disable the execution of TTL jobs, in addition to setting the `TTL_ENABLE='OFF'` table option, you can also disable the execution of TTL jobs in the entire cluster by setting the [`tidb_ttl_job_enable`](/system-variables.md#tidb_ttl_job_enable-new-in-v650) global variable:
Expand Down

0 comments on commit 05248d4

Please sign in to comment.