From f9bbc0e9f1c80db607042ac8df5dd2c5138d05db Mon Sep 17 00:00:00 2001 From: qiancai Date: Thu, 11 May 2023 14:10:16 +0800 Subject: [PATCH 1/4] Update statistics.md --- statistics.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/statistics.md b/statistics.md index 85661d962a14d..0c9f6d2dc5b14 100644 --- a/statistics.md +++ b/statistics.md @@ -358,7 +358,9 @@ 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. +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`](/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. + +### Relevant system variables Three system variables related to automatic update of statistics are as follows: @@ -376,6 +378,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: From 2c2028e563db51e81699cd0896750d568672f12c Mon Sep 17 00:00:00 2001 From: qiancai Date: Thu, 11 May 2023 18:07:31 +0800 Subject: [PATCH 2/4] Update keywords.md --- keywords.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keywords.md b/keywords.md index fbbb89ac377cb..7733ba7693f42 100644 --- a/keywords.md +++ b/keywords.md @@ -656,6 +656,7 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with - THAN - THEN (R) - TIDB (R) +- TiDB_CURRENT_TSO (R) - TIFLASH (R) - TIKV_IMPORTER - TIME @@ -679,7 +680,6 @@ The following list shows the keywords in TiDB. Reserved keywords are marked with - TTL_ENABLE - TTL_JOB_INTERVAL - TYPE -- TiDB_CURRENT_TSO (R) U From 89f7a19d464209d8f04179c4b060b64e9a682bfa Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Thu, 11 May 2023 18:14:18 +0800 Subject: [PATCH 3/4] Update statistics.md --- statistics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statistics.md b/statistics.md index 0c9f6d2dc5b14..f885a3bb9ce22 100644 --- a/statistics.md +++ b/statistics.md @@ -358,7 +358,7 @@ 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`](/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. +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. ### Relevant system variables From 29bd493026f6971b3c88820dfc6f746219c4dcf9 Mon Sep 17 00:00:00 2001 From: qiancai Date: Mon, 22 May 2023 17:08:16 +0800 Subject: [PATCH 4/4] Update statistics.md --- statistics.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/statistics.md b/statistics.md index f885a3bb9ce22..2924921584cdd 100644 --- a/statistics.md +++ b/statistics.md @@ -358,8 +358,18 @@ 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 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. + + + + +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`. + + + ### Relevant system variables Three system variables related to automatic update of statistics are as follows: