Skip to content

Commit

Permalink
Update partitioned-table.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hfxsd authored Dec 23, 2024
1 parent 619181d commit bf11f90
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions partitioned-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -1790,9 +1790,9 @@ ALTER TABLE t1 PARTITION BY HASH (col1) PARTITIONS 3 UPDATE INDEXES (uidx12 LOCA

- If the `GLOBAL` keyword is not explicitly specified in the index definition, TiDB creates a local index by default.
- The `GLOBAL` and `LOCAL` keywords only apply to partitioned tables and do not affect non-partitioned tables. In other words, there is no difference between a global index and a local index in non-partitioned tables.
- Currently, only the creation of Unique Global Indexes is supported. If you need to create a Global Index on a non-unique column, the Global Index must include all the partition columns as a composite index, with the non-unique column appearing first. For example, if the non-unique column is col3 and the partition column is col1, you can use the following command to create a Global Index on the non-unique column col3:"ALTER TABLE xxx ADD UNIQUE KEY(col3, col1) GLOBAL;"
- DDL operations such as `ADD PARTITION`, `DROP PARTITION`, `TRUNCATE PARTITION`, `REORGANIZE PARTITION`, `EXCHANGE PARTITION` also trigger updates to global indexes. The results of these DDL operations will only be returned after the global indexes of the corresponding tables are fully updated. This can delay operations that usually require quick DDL completion, such as data archiving operations (`TRUNCATE PARTITION`, and `DROP PARTITION`). In contrast, when global indexes are not involved, these DDL operations can be completed immediately.
- Tables with a Global Index do not support the EXCHANGE PARTITION operation.
- Currently, TiDB only supports creating unique global indexes. If you need to create a global index on a non-unique column, the global index must include all the partition columns as a composite index, with the non-unique column appearing first. For example, if the non-unique column is `col3` and the partition column is `col1`, you can use the following statement to create a global index on the non-unique column `col3`: `ALTER TABLE ... ADD UNIQUE KEY(col3, col1) GLOBAL;`.
- DDL operations such as `ADD PARTITION`, `DROP PARTITION`, `TRUNCATE PARTITION`, `REORGANIZE PARTITION`, and `EXCHANGE PARTITION` also trigger updates to global indexes. The results of these DDL operations will only be returned after the global indexes of the corresponding tables are fully updated. This can delay operations that usually require quick DDL completion, such as data archiving operations (`TRUNCATE PARTITION` and `DROP PARTITION`). In contrast, when global indexes are not involved, these DDL operations can be completed immediately.
- Tables with global indexes do not support the `EXCHANGE PARTITION` operation.
- By default, the primary key of a partitioned table is a clustered index and must include the partition key. If you require the primary key to exclude the partition key, you can explicitly specify the primary key as a non-clustered global index when creating the table, for example, `PRIMARY KEY(col1, col2) NONCLUSTERED GLOBAL`.
- If a global index is added to an expression column, or a global index is also a prefix index (for example `UNIQUE KEY idx_id_prefix (id(10)) GLOBAL`), you need to collect statistics manually for this global index.

Expand Down

0 comments on commit bf11f90

Please sign in to comment.