Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion keywords.md
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- THAN
- THEN (R)
- TIDB (R)
- TiDB_CURRENT_TSO (R)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is from a comment in pingcap/docs-cn#13871 (comment).

- TIFLASH (R)
- TIKV_IMPORTER
- TIME
Expand All @@ -694,7 +695,6 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with
- TTL_ENABLE
- TTL_JOB_INTERVAL
- TYPE
- TiDB_CURRENT_TSO (R)

<a id="U" class="letter" href="#U">U</a>

Expand Down
20 changes: 19 additions & 1 deletion statistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,19 @@ You can perform incremental collection using the following syntax.

### Automatic update

For the `INSERT`, `DELETE`, or `UPDATE` statements, TiDB automatically updates the number of rows and updated rows. TiDB persists this information regularly and the update cycle is 20 * `stats-lease`. The default value of `stats-lease` is `3s`. If you specify the value as `0`, it does not update automatically.
<CustomContent platform="tidb">

For the `INSERT`, `DELETE`, or `UPDATE` statements, TiDB automatically updates the number of rows and modified rows. TiDB persists this information regularly and the update cycle is 20 * [`stats-lease`](/tidb-configuration-file.md#stats-lease). The default value of `stats-lease` is `3s`. If you specify the value as `0`, TiDB stops updating statistics automatically.

</CustomContent>

<CustomContent platform="tidb-cloud">

For the `INSERT`, `DELETE`, or `UPDATE` statements, TiDB automatically updates the number of rows and modified rows. TiDB persists this information regularly and the update cycle is 20 * `stats-lease`. The default value of `stats-lease` is `3s`.

</CustomContent>

### Relevant system variables

Three system variables related to automatic update of statistics are as follows:

Expand All @@ -376,6 +388,12 @@ To avoid the situation that modifying a small amount of data on a small table fr
>
> Currently, the automatic update does not record the configuration items input at manual `ANALYZE`. Therefore, when you use the `WITH` syntax to control the collecting behavior of `ANALYZE`, you need to manually set scheduled tasks to collect statistics.

#### Disable automatic update

If you find that automatic update of statistics consumes excessive resources and affects online application operations, you can disable it using the [`tidb_enable_auto_analyze`](/system-variables.md#tidb_enable_auto_analyze-new-in-v610) system variable.

#### Terminate background `ANALYZE` tasks

Since TiDB v6.0, TiDB supports using the `KILL` statement to terminate an `ANALYZE` task running in the background. If you find that an `ANALYZE` task running in the background consumes a lot of resources and affects your application, you can terminate the `ANALYZE` task by taking the following steps:

1. Execute the following SQL statement:
Expand Down