Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ttl: updated ttl TTL_JOB_INTERVAL description #19566

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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. The default value is `1h` in v8.5 and earlier versions.
lilin90 marked this conversation as resolved.
Show resolved Hide resolved

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 splits the table into tasks, with the Region as the smallest unit. These tasks are executed distributedly. Typically, a single table can have up to 64 tasks. However, in larger clusters with more than 64 TiKV instances, the maximum number of tasks for a single table is equal to the number of TiKV instances. Note that not all TTL jobs for every type of table can be split into tasks. For more details on which table types are exceptions, see [Limitations](#limitations).
lilin90 marked this conversation as resolved.
Show resolved Hide resolved

TiDB also limits the number of concurrent TTL tasks at the cluster level. You can adjust this concurrency by setting the system variable [`tidb_ttl_running_tasks`](/system-variables.md#tidb_ttl_running_tasks-new-in-v700).

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
Loading