From fc3ce38dc2916ae15164e3ddf6fc34c4e85dcf37 Mon Sep 17 00:00:00 2001 From: Jason Mo Date: Thu, 20 Jun 2024 17:43:36 +0800 Subject: [PATCH 01/13] partition: support global index --- partitioned-table.md | 58 ++++++++++++++++++++++++++++++++++++++++++++ system-variables.md | 6 ++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/partitioned-table.md b/partitioned-table.md index 1a70299593a64..a1e047077a07e 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -1662,6 +1662,64 @@ CREATE TABLE t (a varchar(20), b blob, ERROR 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function ``` +#### Global Index + +If you need to create unique indexes that **don't include all the columns used in the partition expressions**, you can achieve this by enabling the [tidb_enable_global_index](/system-variables.md#tidb_enable_global_index-new-in-v760) variable. + +After enabling this variable, any unique index created by the user that does not meet the above constraint will automatically be converted into a global index. + +{{< copyable "sql" >}} + +```sql +set tidb_enable_global_index = true; + +CREATE TABLE t1 ( + col1 INT NOT NULL, + col2 DATE NOT NULL, + col3 INT NOT NULL, + col4 INT NOT NULL, + UNIQUE KEY uidx12(col1, col2), + UNIQUE KEY uidx3(col3) +) + +PARTITION BY HASH(col3) +PARTITIONS 4; +``` + +In the example above, the unique index `uidx12` will be implicitly converted to a global index, but `uidx3` remains a regular unique index. + +It should be noted that a **clustered index** cannot be a global index: + +{{< copyable "sql" >}} + +```sql +set tidb_enable_global_index = true; + +CREATE TABLE t1 ( + col1 INT NOT NULL, + col2 DATE NOT NULL, + PRIMARY KEY (col2) clustered +) PARTITION BY HASH(col1) PARTITIONS 5; +``` + +```sql +ERROR 1503 (HY000): A CLUSTERED INDEX must include all columns in the table's partitioning function +``` + +Users can identify a global index by querying the `information_schema`.`tidb_indexes` table, aside from checking the table structure. + +```sql +mysql> select * from information_schema.tidb_indexes where table_name='t1'; ++--------------+------------+------------+----------+--------------+-------------+----------+---------------+------------+----------+------------+-----------+-----------+ +| TABLE_SCHEMA | TABLE_NAME | NON_UNIQUE | KEY_NAME | SEQ_IN_INDEX | COLUMN_NAME | SUB_PART | INDEX_COMMENT | Expression | INDEX_ID | IS_VISIBLE | CLUSTERED | IS_GLOBAL | ++--------------+------------+------------+----------+--------------+-------------+----------+---------------+------------+----------+------------+-----------+-----------+ +| test | t1 | 0 | uidx12 | 1 | col1 | NULL | | NULL | 1 | YES | NO | 1 | +| test | t1 | 0 | uidx12 | 2 | col2 | NULL | | NULL | 1 | YES | NO | 1 | +| test | t1 | 0 | uidx3 | 1 | col3 | NULL | | NULL | 2 | YES | NO | 0 | ++--------------+------------+------------+----------+--------------+-------------+----------+---------------+------------+----------+------------+-----------+-----------+ +3 rows in set (0.00 sec) +``` + ### Partitioning limitations relating to functions Only the functions shown in the following list are allowed in partitioning expressions: diff --git a/system-variables.md b/system-variables.md index b422601206af2..da711d96e592c 100644 --- a/system-variables.md +++ b/system-variables.md @@ -2128,13 +2128,17 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1; ### tidb_enable_global_index New in v7.6.0 +> **Warning:** +> +> The feature controlled by this variable is an experimental feature. It is not recommended that you use it in the production environment. This feature might be changed or removed without prior notice. If you find a bug, you can report an [issue](https://github.com/pingcap/tidb/issues) on GitHub. + - Scope: SESSION | GLOBAL - Persists to cluster: Yes - Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No - Type: Boolean - Default value: `OFF` - Possible values: `OFF`, `ON` -- This variable controls whether to support creating `Global indexes` for partitioned tables. `Global index` is currently in the development stage. **It is not recommended to modify the value of this system variable**. +- This variable controls whether to support creating `Global indexes` for partitioned tables. When this variable is enabled, TiDB could create unique indexes that do not contain all columns in the partition expressions. ### tidb_enable_non_prepared_plan_cache From 3cbe2e5adef3f763bb484eb4e3bc41288fa11592 Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Fri, 21 Jun 2024 10:23:11 +0800 Subject: [PATCH 02/13] Update partitioned-table.md Co-authored-by: Mattias Jonsson --- partitioned-table.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/partitioned-table.md b/partitioned-table.md index a1e047077a07e..742a9c6119f1e 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -1666,6 +1666,8 @@ ERROR 1503 (HY000): A UNIQUE INDEX must include all columns in the table's parti If you need to create unique indexes that **don't include all the columns used in the partition expressions**, you can achieve this by enabling the [tidb_enable_global_index](/system-variables.md#tidb_enable_global_index-new-in-v760) variable. +Previously an index on partitioned tables are created for each partition, which is the reason for the limitation that all unique keys needs to include all partitioning columns. Since the uniqueness can only be enforced within each partition. A global index will be created on table level, so it can enforce uniqueness regardless of partitioning. Note that this has implications on partitioning management, DROP, TRUNCATE, REORGANIZE PARTITION will need to also manage the table level global index. + After enabling this variable, any unique index created by the user that does not meet the above constraint will automatically be converted into a global index. {{< copyable "sql" >}} From db1ebf2e12cdc90de4cd98702db4f0dcc542898c Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Fri, 21 Jun 2024 10:23:33 +0800 Subject: [PATCH 03/13] Update partitioned-table.md Co-authored-by: Mattias Jonsson --- partitioned-table.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partitioned-table.md b/partitioned-table.md index 742a9c6119f1e..4204466386e98 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -1668,7 +1668,7 @@ If you need to create unique indexes that **don't include all the columns used i Previously an index on partitioned tables are created for each partition, which is the reason for the limitation that all unique keys needs to include all partitioning columns. Since the uniqueness can only be enforced within each partition. A global index will be created on table level, so it can enforce uniqueness regardless of partitioning. Note that this has implications on partitioning management, DROP, TRUNCATE, REORGANIZE PARTITION will need to also manage the table level global index. -After enabling this variable, any unique index created by the user that does not meet the above constraint will automatically be converted into a global index. +After enabling this variable, any unique index created by the user that does not meet the above constraint will automatically be a global index. {{< copyable "sql" >}} From b1e96dcc4c703c939bcd54c07cc0b480b928e933 Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Fri, 21 Jun 2024 10:23:57 +0800 Subject: [PATCH 04/13] Apply suggestions from code review Co-authored-by: Mattias Jonsson --- partitioned-table.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/partitioned-table.md b/partitioned-table.md index 4204466386e98..da6e06fad4ed4 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -1683,12 +1683,11 @@ CREATE TABLE t1 ( UNIQUE KEY uidx12(col1, col2), UNIQUE KEY uidx3(col3) ) - PARTITION BY HASH(col3) PARTITIONS 4; ``` -In the example above, the unique index `uidx12` will be implicitly converted to a global index, but `uidx3` remains a regular unique index. +In the example above, the unique index `uidx12` will be implicitly a global index, but `uidx3` remains a regular unique index. It should be noted that a **clustered index** cannot be a global index: From 5ed9b56547b9e154158d1cfe8b35b54b42dd3261 Mon Sep 17 00:00:00 2001 From: Jason Mo Date: Fri, 21 Jun 2024 10:52:56 +0800 Subject: [PATCH 05/13] update --- partitioned-table.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/partitioned-table.md b/partitioned-table.md index da6e06fad4ed4..4b889b7baf8ac 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -1707,6 +1707,8 @@ CREATE TABLE t1 ( ERROR 1503 (HY000): A CLUSTERED INDEX must include all columns in the table's partitioning function ``` +The reason is that if the clustered index is a global index, the table will no longer be partitioned. This is because the key of the clustered index is also the record key which means it should be partition level, but the global index is on table level, which creates a conflict. + Users can identify a global index by querying the `information_schema`.`tidb_indexes` table, aside from checking the table structure. ```sql From 6e2a908474cb3fee60c5436725afb0033a02f76b Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Fri, 5 Jul 2024 15:35:55 +0800 Subject: [PATCH 06/13] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- partitioned-table.md | 12 ++++-------- system-variables.md | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/partitioned-table.md b/partitioned-table.md index 4b889b7baf8ac..13e581cc6aeb1 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -1670,10 +1670,9 @@ Previously an index on partitioned tables are created for each partition, which After enabling this variable, any unique index created by the user that does not meet the above constraint will automatically be a global index. -{{< copyable "sql" >}} ```sql -set tidb_enable_global_index = true; +SET tidb_enable_global_index = ON; CREATE TABLE t1 ( col1 INT NOT NULL, @@ -1691,28 +1690,25 @@ In the example above, the unique index `uidx12` will be implicitly a global inde It should be noted that a **clustered index** cannot be a global index: -{{< copyable "sql" >}} ```sql -set tidb_enable_global_index = true; +SET tidb_enable_global_index = ON; CREATE TABLE t1 ( col1 INT NOT NULL, col2 DATE NOT NULL, PRIMARY KEY (col2) clustered ) PARTITION BY HASH(col1) PARTITIONS 5; -``` -```sql ERROR 1503 (HY000): A CLUSTERED INDEX must include all columns in the table's partitioning function ``` The reason is that if the clustered index is a global index, the table will no longer be partitioned. This is because the key of the clustered index is also the record key which means it should be partition level, but the global index is on table level, which creates a conflict. -Users can identify a global index by querying the `information_schema`.`tidb_indexes` table, aside from checking the table structure. +Users can identify a global index by querying the [`information_schema`.`tidb_indexes`](/information-schema/information-schema-tidb-indexes.md) table, aside from checking the table structure. ```sql -mysql> select * from information_schema.tidb_indexes where table_name='t1'; +SELECT * FROM information_schema.tidb_indexes WHERE table_name='t1'; +--------------+------------+------------+----------+--------------+-------------+----------+---------------+------------+----------+------------+-----------+-----------+ | TABLE_SCHEMA | TABLE_NAME | NON_UNIQUE | KEY_NAME | SEQ_IN_INDEX | COLUMN_NAME | SUB_PART | INDEX_COMMENT | Expression | INDEX_ID | IS_VISIBLE | CLUSTERED | IS_GLOBAL | +--------------+------------+------------+----------+--------------+-------------+----------+---------------+------------+----------+------------+-----------+-----------+ diff --git a/system-variables.md b/system-variables.md index da711d96e592c..533a9f5d22239 100644 --- a/system-variables.md +++ b/system-variables.md @@ -2138,7 +2138,7 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1; - Type: Boolean - Default value: `OFF` - Possible values: `OFF`, `ON` -- This variable controls whether to support creating `Global indexes` for partitioned tables. When this variable is enabled, TiDB could create unique indexes that do not contain all columns in the partition expressions. +- This variable controls whether to support creating [`Global indexes`](/partitioned-table.md#global-index) for partitioned tables. When this variable is enabled, TiDB could create unique indexes that do not contain all columns in the partition expressions. ### tidb_enable_non_prepared_plan_cache From 3997a3c3614db621d73606acc64ba9d00cabc620 Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Fri, 5 Jul 2024 15:46:50 +0800 Subject: [PATCH 07/13] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden --- partitioned-table.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/partitioned-table.md b/partitioned-table.md index 13e581cc6aeb1..1e39969a49b02 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -1670,7 +1670,6 @@ Previously an index on partitioned tables are created for each partition, which After enabling this variable, any unique index created by the user that does not meet the above constraint will automatically be a global index. - ```sql SET tidb_enable_global_index = ON; @@ -1690,7 +1689,6 @@ In the example above, the unique index `uidx12` will be implicitly a global inde It should be noted that a **clustered index** cannot be a global index: - ```sql SET tidb_enable_global_index = ON; @@ -1709,6 +1707,9 @@ Users can identify a global index by querying the [`information_schema`.`tidb_in ```sql SELECT * FROM information_schema.tidb_indexes WHERE table_name='t1'; +``` + +``` +--------------+------------+------------+----------+--------------+-------------+----------+---------------+------------+----------+------------+-----------+-----------+ | TABLE_SCHEMA | TABLE_NAME | NON_UNIQUE | KEY_NAME | SEQ_IN_INDEX | COLUMN_NAME | SUB_PART | INDEX_COMMENT | Expression | INDEX_ID | IS_VISIBLE | CLUSTERED | IS_GLOBAL | +--------------+------------+------------+----------+--------------+-------------+----------+---------------+------------+----------+------------+-----------+-----------+ From 5c189acb86574815db081260ca0d453030d69a0d Mon Sep 17 00:00:00 2001 From: Jason Mo Date: Tue, 9 Jul 2024 18:15:36 +0800 Subject: [PATCH 08/13] add placement rules --- placement-rules-in-sql.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/placement-rules-in-sql.md b/placement-rules-in-sql.md index 75d234c5c9c01..ae7427ae195fb 100644 --- a/placement-rules-in-sql.md +++ b/placement-rules-in-sql.md @@ -301,7 +301,9 @@ CREATE PLACEMENT POLICY storageforhisotrydata CONSTRAINTS="[+node=history]"; CREATE PLACEMENT POLICY storagefornewdata CONSTRAINTS="[+node=new]"; CREATE PLACEMENT POLICY companystandardpolicy CONSTRAINTS=""; -CREATE TABLE t1 (id INT, name VARCHAR(50), purchased DATE) +SET tidb_enable_global_index = true; + +CREATE TABLE t1 (id INT, name VARCHAR(50), purchased DATE, UNIQUE INDEX idx(id)) PLACEMENT POLICY=companystandardpolicy PARTITION BY RANGE( YEAR(purchased) ) ( PARTITION p0 VALUES LESS THAN (2000) PLACEMENT POLICY=storageforhisotrydata, @@ -312,12 +314,13 @@ PARTITION BY RANGE( YEAR(purchased) ) ( ); ``` -If no placement policy is specified for a partition in a table, the partition attempts to inherit the policy (if any) from the table. In the preceding example: +If no placement policy is specified for a partition in a table, the partition attempts to inherit the policy (if any) from the table. If the table has a [global index](/partitioned-table.md#global-index), the index will apply the same placement policy as the table. In the preceding example: - The `p0` partition will apply the `storageforhisotrydata` policy. - The `p4` partition will apply the `storagefornewdata` policy. - The `p1`, `p2`, and `p3` partitions will apply the `companystandardpolicy` placement policy inherited from the table `t1`. -- If no placement policy is specified for the table `t1`, the `p1`, `p2`, and `p3` partitions will inherit the database default policy or the global default policy. +- The global index `idx` will apply the `companystandardpolicy` placement policy same as the table `t1`. +- If no placement policy is specified for the table `t1`, the `p1`, `p2`, and `p3` partitions and global index `idx` will inherit the database default policy or the global default policy. After placement policies are attached to these partitions, you can change the placement policy for a specific partition as in the following example: @@ -479,4 +482,4 @@ After executing the statements in the example, TiDB will place the `app_order` d | TiDB Lightning | Not compatible yet | An error is reported when TiDB Lightning imports backup data that contains placement policies | | TiCDC | 6.0 | Ignores placement policies, and does not replicate the policies to the downstream | - \ No newline at end of file + From 791deeef08ee3d534a3efe7d0f36d95130a81e07 Mon Sep 17 00:00:00 2001 From: Jason Mo Date: Tue, 9 Jul 2024 20:59:10 +0800 Subject: [PATCH 09/13] update --- partitioned-table.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/partitioned-table.md b/partitioned-table.md index 1e39969a49b02..1056801d32ee9 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -1697,7 +1697,9 @@ CREATE TABLE t1 ( col2 DATE NOT NULL, PRIMARY KEY (col2) clustered ) PARTITION BY HASH(col1) PARTITIONS 5; +``` +``` ERROR 1503 (HY000): A CLUSTERED INDEX must include all columns in the table's partitioning function ``` From a5729ca35440df137d1442b0fbb33973ca834193 Mon Sep 17 00:00:00 2001 From: Jason Mo Date: Tue, 9 Jul 2024 21:00:58 +0800 Subject: [PATCH 10/13] update --- placement-rules-in-sql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/placement-rules-in-sql.md b/placement-rules-in-sql.md index ae7427ae195fb..bc6d0cba09ea4 100644 --- a/placement-rules-in-sql.md +++ b/placement-rules-in-sql.md @@ -301,7 +301,7 @@ CREATE PLACEMENT POLICY storageforhisotrydata CONSTRAINTS="[+node=history]"; CREATE PLACEMENT POLICY storagefornewdata CONSTRAINTS="[+node=new]"; CREATE PLACEMENT POLICY companystandardpolicy CONSTRAINTS=""; -SET tidb_enable_global_index = true; +SET tidb_enable_global_index = ON; CREATE TABLE t1 (id INT, name VARCHAR(50), purchased DATE, UNIQUE INDEX idx(id)) PLACEMENT POLICY=companystandardpolicy From 6004f5ed49174c4132c24bd3a4aaca06908860e9 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 31 Jul 2024 16:51:02 +0800 Subject: [PATCH 11/13] Apply suggestions from code review --- partitioned-table.md | 16 ++++++++-------- placement-rules-in-sql.md | 6 +++--- system-variables.md | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/partitioned-table.md b/partitioned-table.md index 1056801d32ee9..5b6735c36dd88 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -1662,13 +1662,13 @@ CREATE TABLE t (a varchar(20), b blob, ERROR 1503 (HY000): A UNIQUE INDEX must include all columns in the table's partitioning function ``` -#### Global Index +#### Global indexes -If you need to create unique indexes that **don't include all the columns used in the partition expressions**, you can achieve this by enabling the [tidb_enable_global_index](/system-variables.md#tidb_enable_global_index-new-in-v760) variable. +If you need to create unique indexes that **do not include all the columns used in the partition expressions**, you can achieve this by enabling the [`tidb_enable_global_index`](/system-variables.md#tidb_enable_global_index-new-in-v760) system variable. -Previously an index on partitioned tables are created for each partition, which is the reason for the limitation that all unique keys needs to include all partitioning columns. Since the uniqueness can only be enforced within each partition. A global index will be created on table level, so it can enforce uniqueness regardless of partitioning. Note that this has implications on partitioning management, DROP, TRUNCATE, REORGANIZE PARTITION will need to also manage the table level global index. +Previously an index on partitioned tables are created for each partition, which is the reason for the limitation that all unique keys need to include all partitioning columns. The uniqueness can only be enforced within each partition. A global index will be created on table level, so it can enforce uniqueness regardless of partitioning. Note that this has implications on partitioning management, `DROP`, `TRUNCATE`, and `REORGANIZE PARTITION` will also need to manage the table level global index. -After enabling this variable, any unique index created by the user that does not meet the above constraint will automatically be a global index. +After enabling this variable, any unique index that does not meet the preceding constraint will automatically become a global index. ```sql SET tidb_enable_global_index = ON; @@ -1685,9 +1685,9 @@ PARTITION BY HASH(col3) PARTITIONS 4; ``` -In the example above, the unique index `uidx12` will be implicitly a global index, but `uidx3` remains a regular unique index. +In this example, the unique index `uidx12` will be implicitly a global index, but `uidx3` remains a regular unique index. -It should be noted that a **clustered index** cannot be a global index: +Note that a **clustered index** cannot be a global index, as shown in the following example: ```sql SET tidb_enable_global_index = ON; @@ -1703,9 +1703,9 @@ CREATE TABLE t1 ( ERROR 1503 (HY000): A CLUSTERED INDEX must include all columns in the table's partitioning function ``` -The reason is that if the clustered index is a global index, the table will no longer be partitioned. This is because the key of the clustered index is also the record key which means it should be partition level, but the global index is on table level, which creates a conflict. +The reason is that if the clustered index is a global index, the table will no longer be partitioned. This is because the key of the clustered index is also the record key, which means it should be on partition level. But the global index is on table level, which causes a conflict. -Users can identify a global index by querying the [`information_schema`.`tidb_indexes`](/information-schema/information-schema-tidb-indexes.md) table, aside from checking the table structure. +You can identify a global index by querying the [`information_schema.tidb_indexes`](/information-schema/information-schema-tidb-indexes.md) table and checking the table structure. ```sql SELECT * FROM information_schema.tidb_indexes WHERE table_name='t1'; diff --git a/placement-rules-in-sql.md b/placement-rules-in-sql.md index bc6d0cba09ea4..c2eee63e7b7e5 100644 --- a/placement-rules-in-sql.md +++ b/placement-rules-in-sql.md @@ -314,13 +314,13 @@ PARTITION BY RANGE( YEAR(purchased) ) ( ); ``` -If no placement policy is specified for a partition in a table, the partition attempts to inherit the policy (if any) from the table. If the table has a [global index](/partitioned-table.md#global-index), the index will apply the same placement policy as the table. In the preceding example: +If no placement policy is specified for a partition in a table, the partition attempts to inherit the policy (if any) from the table. If the table has a [global index](/partitioned-table.md#global-indexes), the index will apply the same placement policy as the table. In the preceding example: - The `p0` partition will apply the `storageforhisotrydata` policy. - The `p4` partition will apply the `storagefornewdata` policy. - The `p1`, `p2`, and `p3` partitions will apply the `companystandardpolicy` placement policy inherited from the table `t1`. -- The global index `idx` will apply the `companystandardpolicy` placement policy same as the table `t1`. -- If no placement policy is specified for the table `t1`, the `p1`, `p2`, and `p3` partitions and global index `idx` will inherit the database default policy or the global default policy. +- The global index `idx` will apply the same `companystandardpolicy` placement policy as the table `t1`. +- If no placement policy is specified for the table `t1`, the `p1`, `p2`, and `p3` partitions, the global index `idx` will inherit the database default policy or the global default policy. After placement policies are attached to these partitions, you can change the placement policy for a specific partition as in the following example: diff --git a/system-variables.md b/system-variables.md index 533a9f5d22239..193089145a30a 100644 --- a/system-variables.md +++ b/system-variables.md @@ -2138,7 +2138,7 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1; - Type: Boolean - Default value: `OFF` - Possible values: `OFF`, `ON` -- This variable controls whether to support creating [`Global indexes`](/partitioned-table.md#global-index) for partitioned tables. When this variable is enabled, TiDB could create unique indexes that do not contain all columns in the partition expressions. +- This variable controls whether to support creating [`global indexes`](/partitioned-table.md#global-indexes) for partitioned tables. When this variable is enabled, TiDB creates unique indexes that do not contain all columns in the partition expressions. ### tidb_enable_non_prepared_plan_cache From c4842dcbf46298080631096a6acb60ddc3842028 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 1 Aug 2024 10:31:15 +0800 Subject: [PATCH 12/13] Update placement-rules-in-sql.md --- placement-rules-in-sql.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/placement-rules-in-sql.md b/placement-rules-in-sql.md index c2eee63e7b7e5..310df46789922 100644 --- a/placement-rules-in-sql.md +++ b/placement-rules-in-sql.md @@ -320,7 +320,7 @@ If no placement policy is specified for a partition in a table, the partition at - The `p4` partition will apply the `storagefornewdata` policy. - The `p1`, `p2`, and `p3` partitions will apply the `companystandardpolicy` placement policy inherited from the table `t1`. - The global index `idx` will apply the same `companystandardpolicy` placement policy as the table `t1`. -- If no placement policy is specified for the table `t1`, the `p1`, `p2`, and `p3` partitions, the global index `idx` will inherit the database default policy or the global default policy. +- If no placement policy is specified for the table `t1`, then the `p1`, `p2`, and `p3` partitions and the global index `idx` will inherit the database default policy or the global default policy. After placement policies are attached to these partitions, you can change the placement policy for a specific partition as in the following example: From 58aa8a27c4d7a77f1387a52b4f410f03abd2b232 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Tue, 6 Aug 2024 09:51:49 +0800 Subject: [PATCH 13/13] Update system-variables.md --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index 193089145a30a..7209bba763d48 100644 --- a/system-variables.md +++ b/system-variables.md @@ -2138,7 +2138,7 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1; - Type: Boolean - Default value: `OFF` - Possible values: `OFF`, `ON` -- This variable controls whether to support creating [`global indexes`](/partitioned-table.md#global-indexes) for partitioned tables. When this variable is enabled, TiDB creates unique indexes that do not contain all columns in the partition expressions. +- This variable controls whether to support creating [global indexes](/partitioned-table.md#global-indexes) for partitioned tables. When this variable is enabled, TiDB creates unique indexes that do not contain all columns in the partition expressions. ### tidb_enable_non_prepared_plan_cache