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

add some point desc #11454

Merged
merged 3 commits into from
Sep 30, 2022
Merged
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
16 changes: 7 additions & 9 deletions statistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ TiDB 使用统计信息来决定[索引的选择](/choose-index.md)。变量 `ti
>
> - 如果 ANALYZE 语句是手动执行的,请手动 analyze 每张需要的表:
>
> {{< copyable "sql" >}}
>
> ```sql
> select distinct(concat('ANALYZE ',table_schema, '.', table_name,';')) from information_schema.tables, mysql.stats_histograms where stats_ver = 2 and table_id = tidb_table_id ;
> ```
> ```sql
> SELECT DISTINCT(CONCAT('ANALYZE TABLE', table_schema, '.', table_name, ';')) FROM information_schema.tables, mysql.stats_histograms WHERE stats_ver = 2 AND table_id = tidb_table_id;
> ```
>
> - 如果 ANALYZE 语句是开启了自动 analyze 后 TiDB 自动执行的,请使用以下 SQL 语句生成 DROP STATS 的语句并执行:
>
> {{< copyable "sql" >}}
>
> ```sql
> select distinct(concat('DROP STATS ',table_schema, '.', table_name,';')) from information_schema.tables, mysql.stats_histograms where stats_ver = 2 and table_id = tidb_table_id ;
> ```
> ```sql
> SELECT DISTINCT(CONCAT('DROP STATS ', table_schema, '.', table_name, ';')) FROM information_schema.tables, mysql.stats_histograms WHERE stats_ver = 2 AND table_id = tidb_table_id;
> ```

两种版本中,TiDB 维护的统计信息如下:

Expand Down Expand Up @@ -140,7 +138,7 @@ ANALYZE TABLE TableNameList [WITH NUM BUCKETS|TOPN|CMSKETCH DEPTH|CMSKETCH WIDTH

> **注意:**
>
> 该语法为全量收集。例如,在使用该语法收集了 a 列和 b 列的统计信息之后,如果还想要增加收集 c 列的统计信息,需要在语法中同时指定这三列 `ANALYZE table t columns a, b, c`,而不是只指定新增的那一列 `ANALYZE TABLE t COLUMNS c`。
> 该语法为全量收集。例如,在使用该语法收集了 a 列和 b 列的统计信息之后,如果还想要增加收集 c 列的统计信息,需要在语法中同时指定这三列 `ANALYZE TABLE t columns a, b, c`,而不是只指定新增的那一列 `ANALYZE TABLE t COLUMNS c`。

- 如果要收集 `PREDICATE COLUMNS` 的统计信息,请进行以下操作:

Expand Down