From 68abb7dc00429745732bdb463ece96f000c6a35a Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Fri, 23 Sep 2022 16:27:44 +0800 Subject: [PATCH 1/4] This is an automated cherry-pick of #10534 Signed-off-by: ti-chi-bot --- extended-statistics.md | 16 ++++++++++++++++ system-variables.md | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/extended-statistics.md b/extended-statistics.md index 614ac02ce1e33..9fce7ba15ba07 100644 --- a/extended-statistics.md +++ b/extended-statistics.md @@ -7,18 +7,30 @@ summary: Learn how to use extended statistics to guide the optimizer. TiDB can collect the following two types of statistics: +<<<<<<< HEAD - Regular statistics: statistics such as histograms and Count-Min Sketch. See [Introduction to Statistics](/statistics.md) for details. +======= +- Basic statistics: statistics such as histograms and Count-Min Sketch. See [Introduction to Statistics](/statistics.md) for details. +>>>>>>> b270933fe (statistics: add some doc for the exp feature (#9891) (#10534)) - Extended statistics: statistics filtered by tables and columns. > **Tip:** > > Before reading this document, it is recommended that you read [Introduction to Statistics](/statistics.md) first. +<<<<<<< HEAD When the `ANALYZE` statement is executed manually or automatically, TiDB by default only collects the regular statistics and does not collect the extended statistics. This is because the extended statistics are only used for optimizer estimates in specific scenarios, and collecting them requires additional overhead. Extended statistics are disabled by default. To collect extended statistics, you need to first enable the extended statistics, and then register each individual extended statistics object. After the registration, the next time the `ANALYZE` statement is executed, TiDB collects both the regular statistics and the registered extended statistics. +======= +When the `ANALYZE` statement is executed manually or automatically, TiDB by default only collects the basic statistics and does not collect the extended statistics. This is because the extended statistics are only used for optimizer estimates in specific scenarios, and collecting them requires additional overhead. + +Extended statistics are disabled by default. To collect extended statistics, you need to first enable the extended statistics, and then register each individual extended statistics object. + +After the registration, the next time the `ANALYZE` statement is executed, TiDB collects both the basic statistics and the registered extended statistics. +>>>>>>> b270933fe (statistics: add some doc for the exp feature (#9891) (#10534)) ## Limitations @@ -107,7 +119,11 @@ Other TiDB nodes will read this change and delete the object in their memory cac ### Export and import extended statistics +<<<<<<< HEAD The way of exporting or importing extended statistics is the same as exporting or importing regular statistics. See [Introduction to Statistics - Import and export statistics](/statistics.md#import-and-export-statistics) for details. +======= +The way of exporting or importing extended statistics is the same as exporting or importing basic statistics. See [Introduction to Statistics - Import and export statistics](/statistics.md#import-and-export-statistics) for details. +>>>>>>> b270933fe (statistics: add some doc for the exp feature (#9891) (#10534)) ## Usage examples for correlation-type extended statistics diff --git a/system-variables.md b/system-variables.md index d9195ded281d0..264df3bb03187 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1155,6 +1155,7 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - `RESTRICTED_VARIABLES_ADMIN`: The ability to see and set sensitive variables in `SHOW [GLOBAL] VARIABLES` and `SET`. - `RESTRICTED_USER_ADMIN`: The ability to prevent other users from making changes or dropping a user account. +<<<<<<< HEAD ### tidb_enable_exchange_partition - Scope: SESSION | GLOBAL @@ -1164,6 +1165,8 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - This variable controls whether to enable the [`exchange partitions with tables`](/partitioned-table.md#partition-management) feature. The default value is `ON`, that is, `exchange partitions with tables` is enabled by default. - This variable is deprecated since v6.3.0. Its value will be fixed to the default value `ON`, that is, `exchange partitions with tables` is enabled by default. +======= +>>>>>>> b270933fe (statistics: add some doc for the exp feature (#9891) (#10534)) ### tidb_enable_extended_stats @@ -2512,6 +2515,7 @@ explain select * from t where age=5; - Default value: `OFF` - This variable is used to control whether to allow `INSERT`, `REPLACE`, and `UPDATE` statements to operate on the `_tidb_rowid` column. This variable can be used only when you import data using TiDB tools. +<<<<<<< HEAD ### tidb_opt_force_inline_cte New in v6.3.0 - Scope: SESSION | GLOBAL @@ -2520,6 +2524,8 @@ explain select * from t where age=5; - Default value: `OFF` - This variable is used to control whether common table expressions (CTEs) in the entire session are inlined or not. The default value is `OFF`, which means that inlining CTE is not enforced by default. However, you can still inline CTE by specifying the `MERGE()` hint. If the variable is set to `ON`, all CTEs (except recursive CTE) in this session are forced to be inlined. +======= +>>>>>>> b270933fe (statistics: add some doc for the exp feature (#9891) (#10534)) ### tidb_optimizer_selectivity_level - Scope: SESSION | GLOBAL From dc303fc95242bfdf1565043dbc361e4efa0e0f4b Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Fri, 23 Sep 2022 16:33:41 +0800 Subject: [PATCH 2/4] Apply suggestions from code review --- extended-statistics.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/extended-statistics.md b/extended-statistics.md index 9fce7ba15ba07..2060544cbc327 100644 --- a/extended-statistics.md +++ b/extended-statistics.md @@ -7,11 +7,7 @@ summary: Learn how to use extended statistics to guide the optimizer. TiDB can collect the following two types of statistics: -<<<<<<< HEAD -- Regular statistics: statistics such as histograms and Count-Min Sketch. See [Introduction to Statistics](/statistics.md) for details. -======= -- Basic statistics: statistics such as histograms and Count-Min Sketch. See [Introduction to Statistics](/statistics.md) for details. ->>>>>>> b270933fe (statistics: add some doc for the exp feature (#9891) (#10534)) +Basics: statistics such as histograms and Count-Min Sketch. See [Introduction to Statistics](/statistics.md) for details. - Extended statistics: statistics filtered by tables and columns. > **Tip:** @@ -119,11 +115,7 @@ Other TiDB nodes will read this change and delete the object in their memory cac ### Export and import extended statistics -<<<<<<< HEAD -The way of exporting or importing extended statistics is the same as exporting or importing regular statistics. See [Introduction to Statistics - Import and export statistics](/statistics.md#import-and-export-statistics) for details. -======= The way of exporting or importing extended statistics is the same as exporting or importing basic statistics. See [Introduction to Statistics - Import and export statistics](/statistics.md#import-and-export-statistics) for details. ->>>>>>> b270933fe (statistics: add some doc for the exp feature (#9891) (#10534)) ## Usage examples for correlation-type extended statistics From 21292284853eab683f133c3780a2c123ab182579 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Fri, 23 Sep 2022 19:05:44 +0800 Subject: [PATCH 3/4] resolve --- extended-statistics.md | 8 -------- system-variables.md | 6 ------ 2 files changed, 14 deletions(-) diff --git a/extended-statistics.md b/extended-statistics.md index 2060544cbc327..d53e509a37f8e 100644 --- a/extended-statistics.md +++ b/extended-statistics.md @@ -14,19 +14,11 @@ Basics: statistics such as histograms and Count-Min Sketch. See [Introduction to > > Before reading this document, it is recommended that you read [Introduction to Statistics](/statistics.md) first. -<<<<<<< HEAD -When the `ANALYZE` statement is executed manually or automatically, TiDB by default only collects the regular statistics and does not collect the extended statistics. This is because the extended statistics are only used for optimizer estimates in specific scenarios, and collecting them requires additional overhead. - -Extended statistics are disabled by default. To collect extended statistics, you need to first enable the extended statistics, and then register each individual extended statistics object. - -After the registration, the next time the `ANALYZE` statement is executed, TiDB collects both the regular statistics and the registered extended statistics. -======= When the `ANALYZE` statement is executed manually or automatically, TiDB by default only collects the basic statistics and does not collect the extended statistics. This is because the extended statistics are only used for optimizer estimates in specific scenarios, and collecting them requires additional overhead. Extended statistics are disabled by default. To collect extended statistics, you need to first enable the extended statistics, and then register each individual extended statistics object. After the registration, the next time the `ANALYZE` statement is executed, TiDB collects both the basic statistics and the registered extended statistics. ->>>>>>> b270933fe (statistics: add some doc for the exp feature (#9891) (#10534)) ## Limitations diff --git a/system-variables.md b/system-variables.md index 264df3bb03187..d9195ded281d0 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1155,7 +1155,6 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - `RESTRICTED_VARIABLES_ADMIN`: The ability to see and set sensitive variables in `SHOW [GLOBAL] VARIABLES` and `SET`. - `RESTRICTED_USER_ADMIN`: The ability to prevent other users from making changes or dropping a user account. -<<<<<<< HEAD ### tidb_enable_exchange_partition - Scope: SESSION | GLOBAL @@ -1165,8 +1164,6 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - This variable controls whether to enable the [`exchange partitions with tables`](/partitioned-table.md#partition-management) feature. The default value is `ON`, that is, `exchange partitions with tables` is enabled by default. - This variable is deprecated since v6.3.0. Its value will be fixed to the default value `ON`, that is, `exchange partitions with tables` is enabled by default. -======= ->>>>>>> b270933fe (statistics: add some doc for the exp feature (#9891) (#10534)) ### tidb_enable_extended_stats @@ -2515,7 +2512,6 @@ explain select * from t where age=5; - Default value: `OFF` - This variable is used to control whether to allow `INSERT`, `REPLACE`, and `UPDATE` statements to operate on the `_tidb_rowid` column. This variable can be used only when you import data using TiDB tools. -<<<<<<< HEAD ### tidb_opt_force_inline_cte New in v6.3.0 - Scope: SESSION | GLOBAL @@ -2524,8 +2520,6 @@ explain select * from t where age=5; - Default value: `OFF` - This variable is used to control whether common table expressions (CTEs) in the entire session are inlined or not. The default value is `OFF`, which means that inlining CTE is not enforced by default. However, you can still inline CTE by specifying the `MERGE()` hint. If the variable is set to `ON`, all CTEs (except recursive CTE) in this session are forced to be inlined. -======= ->>>>>>> b270933fe (statistics: add some doc for the exp feature (#9891) (#10534)) ### tidb_optimizer_selectivity_level - Scope: SESSION | GLOBAL From 7e8d8e3765f3f41d3b93643108aeeccf98bb8de3 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Mon, 26 Sep 2022 11:47:34 +0800 Subject: [PATCH 4/4] Update extended-statistics.md --- extended-statistics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extended-statistics.md b/extended-statistics.md index d53e509a37f8e..b6a2fae9456c7 100644 --- a/extended-statistics.md +++ b/extended-statistics.md @@ -7,7 +7,7 @@ summary: Learn how to use extended statistics to guide the optimizer. TiDB can collect the following two types of statistics: -Basics: statistics such as histograms and Count-Min Sketch. See [Introduction to Statistics](/statistics.md) for details. +- Basic statistics: statistics such as histograms and Count-Min Sketch. See [Introduction to Statistics](/statistics.md) for details. - Extended statistics: statistics filtered by tables and columns. > **Tip:**