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

partition: global index GA & deprecated tidb_enable_table_partition, tidb_enable_list_partition and tidb_enable_global_index #18659

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
5 changes: 1 addition & 4 deletions partitioned-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -1680,10 +1680,6 @@ ERROR 1503 (HY000): A UNIQUE INDEX must include all columns in the table's parti

为解决这些问题,TiDB 从 v8.3.0 开始引入全局索引。全局索引能覆盖整个表的数据,使得主键和唯一键在不包含分区键的情况下仍能保持全局唯一性。同时,全局索引可以在一次操作中访问多个分区的数据,显著提升了针对非分区键的查询性能。

> **警告:**
>
> 全局索引目前为实验特性,不建议在生产环境中使用。该功能可能会在未事先通知的情况下发生变化或删除。如果发现 bug,请在 GitHub 上提 [issue](https://github.com/pingcap/tidb/issues) 反馈。

如果你需要创建的唯一索引**不包含分区表达式中使用的所有列**,可以通过启用 [`tidb_enable_global_index`](/system-variables.md#tidb_enable_global_index-从-v760-版本开始引入) 系统变量并在索引定义中添加 `GLOBAL` 关键字来实现。

> **注意:**
Expand Down Expand Up @@ -1774,6 +1770,7 @@ ALTER TABLE t1 PARTITION BY HASH (col1) PARTITIONS 3 UPDATE INDEXES (uidx12 LOCA
- `GLOBAL` 和 `LOCAL` 关键字仅适用于分区表,对非分区表没有影响。即在非分区表中,全局索引和局部索引之间没有区别。
- DDL 操作如 `ADD PARTITION`、`DROP PARTITION`、`TRUNCATE PARTITION`、`REORGANIZE PARTITION`、`SPLIT PARTITION` 和 `EXCHANGE PARTITION` 等也会触发对全局索引的更新,这些 DDL 的执行结果将在全局索引更新完成后才会返回。因此,这可能会延迟一些通常需要快速完成的 DDL 的操作,如数据归档操作(`EXCHANGE PARTITION`、`TRUNCATE PARTITION` 和 `DROP PARTITION`)。而如果没有全局索引,这些 DDL 操作可以立即执行完成。
- 默认情况下,分区表的主键为聚簇索引,且必须包含分区键。如果要求主键不包含分区建,可以在建表时显式指定主键为非聚簇的全局索引,例如:`PRIMARY KEY(col1, col2) NONCLUSTERED GLOBAL`。
- 如果在表达式列上添加了全局索引,该全局索引需要手动收集统计信息。
hfxsd marked this conversation as resolved.
Show resolved Hide resolved

### 关于函数的分区限制

Expand Down
4 changes: 0 additions & 4 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -1935,10 +1935,6 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1;

### `tidb_enable_global_index` <span class="version-mark">从 v7.6.0 版本开始引入</span>

> **警告:**
>
> 该变量控制的功能为实验特性,不建议在生产环境中使用。该功能可能会在未事先通知的情况下发生变化或删除。如果发现 bug,请在 GitHub 上提 [issue](https://github.com/pingcap/tidb/issues) 反馈。

- 作用域:SESSION | GLOBAL
- 是否持久化到集群:是
- 是否受 Hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value) 控制:否
Expand Down