From 0d6b9c046edf7ac541f5c479abdd9a141533f20d Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 26 Apr 2021 08:56:34 +0200 Subject: [PATCH 1/8] partitioning: Corrected partition management Clarified currently supported partitioning management, and added experimental feature EXCHANGE PARTITION. Fixes https://github.com/pingcap/docs/issues/5424 --- partitioned-table.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/partitioned-table.md b/partitioned-table.md index 9f24457367ce7..c5bb0f4d89fe0 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -578,7 +578,15 @@ You can see that the inserted record `(NULL, 'mothra')` falls into the same part ## Partition management -You can add, drop, merge, split, redefine partitions by using `ALTER TABLE` statements. +For `LIST` and `RANGE` partitioned tables, you can add and drop partitions with `ALTER TABLE ADD PARTITION ()` / `ALTER TABLE
DROP PARTITION ` +For `HASH` partitioned tables, `COALESCE PARTITION` and `ADD PARTITION` is not yet supported. +`REORGANIZE PARTITION` is not yet supported. + +> **Warning** +> `EXCHANGE PARTITION` is an experimental feature and should not be used in production environment, it can be enabled by setting `tidb_enable_exchange_partition` system variable to ON. +> +> It works by swapping a partition and a non partitioned table, similar to how rename table like `RENAME TABLE t1 TO t1_tmp, t2 TO t1, t1_tmp TO t2` works. +> `ALTER TABLE partitioned_table EXCHANGE PARTITION p1 WITH TABLE non_partitioned_table` ### Range partition management From b315fad69971dfcefc20dd1d0130bff835dc511c Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Mon, 26 Apr 2021 09:25:31 +0200 Subject: [PATCH 2/8] partitioning: fixed linting/line breaks. --- partitioned-table.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/partitioned-table.md b/partitioned-table.md index c5bb0f4d89fe0..b8c9a7501a842 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -578,8 +578,10 @@ You can see that the inserted record `(NULL, 'mothra')` falls into the same part ## Partition management -For `LIST` and `RANGE` partitioned tables, you can add and drop partitions with `ALTER TABLE
ADD PARTITION ()` / `ALTER TABLE
DROP PARTITION ` +For `LIST` and `RANGE` partitioned tables, you can add and drop partitions with `ALTER TABLE
ADD PARTITION ()` / `ALTER TABLE
DROP PARTITION `. + For `HASH` partitioned tables, `COALESCE PARTITION` and `ADD PARTITION` is not yet supported. + `REORGANIZE PARTITION` is not yet supported. > **Warning** From 4aab13db17f6803c465b50f94b4acda4216a1edd Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 11 May 2021 17:47:33 +0200 Subject: [PATCH 3/8] Update partitioned-table.md According to TomShawn's suggestion, to better English. Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> --- partitioned-table.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partitioned-table.md b/partitioned-table.md index b8c9a7501a842..406391fb22ca0 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -578,7 +578,7 @@ You can see that the inserted record `(NULL, 'mothra')` falls into the same part ## Partition management -For `LIST` and `RANGE` partitioned tables, you can add and drop partitions with `ALTER TABLE
ADD PARTITION ()` / `ALTER TABLE
DROP PARTITION `. +For `LIST` and `RANGE` partitioned tables, you can add and drop partitions using the `ALTER TABLE
ADD PARTITION ()` or `ALTER TABLE
DROP PARTITION ` statement. For `HASH` partitioned tables, `COALESCE PARTITION` and `ADD PARTITION` is not yet supported. From adf3ddb0f59bd15df9753779a2f813d1e3763f74 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Tue, 11 May 2021 17:48:44 +0200 Subject: [PATCH 4/8] Update partitioned-table.md Better formatting for EXCHANGE PARTITION (not yet GA feature). Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> --- partitioned-table.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/partitioned-table.md b/partitioned-table.md index 406391fb22ca0..03d4a13b593ec 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -584,11 +584,13 @@ For `HASH` partitioned tables, `COALESCE PARTITION` and `ADD PARTITION` is not y `REORGANIZE PARTITION` is not yet supported. -> **Warning** -> `EXCHANGE PARTITION` is an experimental feature and should not be used in production environment, it can be enabled by setting `tidb_enable_exchange_partition` system variable to ON. +> **Warning:** +> +> - `EXCHANGE PARTITION` is an experimental feature. It is not recommended to use it in a production environment. To enable it, set the `tidb_enable_exchange_partition` system variable to `ON`. > -> It works by swapping a partition and a non partitioned table, similar to how rename table like `RENAME TABLE t1 TO t1_tmp, t2 TO t1, t1_tmp TO t2` works. -> `ALTER TABLE partitioned_table EXCHANGE PARTITION p1 WITH TABLE non_partitioned_table` +> - It works by swapping a partition and a non-partitioned table, similar to how renaming a table like `RENAME TABLE t1 TO t1_tmp, t2 TO t1, t1_tmp TO t2` works. +> +> - `ALTER TABLE partitioned_table EXCHANGE PARTITION p1 WITH TABLE non_partitioned_table` ### Range partition management From 53e7f757e2fa16da24d94fbc014fd0a3ccca7095 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 30 Jun 2021 00:59:06 +0200 Subject: [PATCH 5/8] Updated partitioning management text according to review comments --- partitioned-table.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/partitioned-table.md b/partitioned-table.md index 03d4a13b593ec..a31acfc57c1fa 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -580,17 +580,19 @@ You can see that the inserted record `(NULL, 'mothra')` falls into the same part For `LIST` and `RANGE` partitioned tables, you can add and drop partitions using the `ALTER TABLE
ADD PARTITION ()` or `ALTER TABLE
DROP PARTITION ` statement. -For `HASH` partitioned tables, `COALESCE PARTITION` and `ADD PARTITION` is not yet supported. +For `HASH` partitioned tables, `COALESCE PARTITION` and `ADD PARTITION` are not yet supported. `REORGANIZE PARTITION` is not yet supported. > **Warning:** > > - `EXCHANGE PARTITION` is an experimental feature. It is not recommended to use it in a production environment. To enable it, set the `tidb_enable_exchange_partition` system variable to `ON`. -> -> - It works by swapping a partition and a non-partitioned table, similar to how renaming a table like `RENAME TABLE t1 TO t1_tmp, t2 TO t1, t1_tmp TO t2` works. > -> - `ALTER TABLE partitioned_table EXCHANGE PARTITION p1 WITH TABLE non_partitioned_table` +> - `EXCHANGE PARTITION` works by swapping a partition and a non-partitioned table, similar to how renaming a table like `RENAME TABLE t1 TO t1_tmp, t2 TO t1, t1_tmp TO t2` works. +> +> - As an example: `ALTER TABLE partitioned_table EXCHANGE PARTITION p1 WITH TABLE non_partitioned_table`, swaps the table `non_partitioned_table` with the partition `p1` in the `partitioned_table` table. +> +> Please be sure that all rows you are exchanging into the partition are matching the partition definition, or else they will not be found and there may be other issues. ### Range partition management From bf679b4b3e26909ed8cf14b79ca7ce75e796991b Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 30 Jun 2021 09:15:55 +0200 Subject: [PATCH 6/8] Reformatted the Warning section about EXCHANGE partition --- partitioned-table.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/partitioned-table.md b/partitioned-table.md index a31acfc57c1fa..15103a72de18f 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -580,19 +580,19 @@ You can see that the inserted record `(NULL, 'mothra')` falls into the same part For `LIST` and `RANGE` partitioned tables, you can add and drop partitions using the `ALTER TABLE
ADD PARTITION ()` or `ALTER TABLE
DROP PARTITION ` statement. +For `LIST and `RANGE` partitioned tables, `REORGANIZE PARTITION` is not yet supported. + For `HASH` partitioned tables, `COALESCE PARTITION` and `ADD PARTITION` are not yet supported. -`REORGANIZE PARTITION` is not yet supported. +`EXCHANGE PARTITION` works by swapping a partition and a non-partitioned table, similar to how renaming a table like `RENAME TABLE t1 TO t1_tmp, t2 TO t1, t1_tmp TO t2` works. + +- As an example: `ALTER TABLE partitioned_table EXCHANGE PARTITION p1 WITH TABLE non_partitioned_table`, swaps the table `non_partitioned_table` with the partition `p1` in the `partitioned_table` table. + +Please be sure that all rows you are exchanging into the partition are matching the partition definition, or else they will not be found and there may be other issues. > **Warning:** > -> - `EXCHANGE PARTITION` is an experimental feature. It is not recommended to use it in a production environment. To enable it, set the `tidb_enable_exchange_partition` system variable to `ON`. -> -> - `EXCHANGE PARTITION` works by swapping a partition and a non-partitioned table, similar to how renaming a table like `RENAME TABLE t1 TO t1_tmp, t2 TO t1, t1_tmp TO t2` works. -> -> - As an example: `ALTER TABLE partitioned_table EXCHANGE PARTITION p1 WITH TABLE non_partitioned_table`, swaps the table `non_partitioned_table` with the partition `p1` in the `partitioned_table` table. -> -> Please be sure that all rows you are exchanging into the partition are matching the partition definition, or else they will not be found and there may be other issues. +> - `EXCHANGE PARTITION` is an experimental feature. It is not yet recommended to use it in a production environment. To enable it, set the `tidb_enable_exchange_partition` system variable to `ON`. ### Range partition management From 288b35eccf29e1c3da0c7d2ea0a0d351e8f72636 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Fri, 23 Jul 2021 15:54:54 +0800 Subject: [PATCH 7/8] Update partitioned-table.md --- partitioned-table.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/partitioned-table.md b/partitioned-table.md index 15103a72de18f..ab99afb9d0057 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -580,7 +580,7 @@ You can see that the inserted record `(NULL, 'mothra')` falls into the same part For `LIST` and `RANGE` partitioned tables, you can add and drop partitions using the `ALTER TABLE
ADD PARTITION ()` or `ALTER TABLE
DROP PARTITION ` statement. -For `LIST and `RANGE` partitioned tables, `REORGANIZE PARTITION` is not yet supported. +For `LIST` and `RANGE` partitioned tables, `REORGANIZE PARTITION` is not yet supported. For `HASH` partitioned tables, `COALESCE PARTITION` and `ADD PARTITION` are not yet supported. From 157ca887dee6cdbd064add471c453d5b1476d247 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Fri, 23 Jul 2021 16:00:23 +0800 Subject: [PATCH 8/8] Update partitioned-table.md --- partitioned-table.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/partitioned-table.md b/partitioned-table.md index ab99afb9d0057..814f22eeb0740 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -586,13 +586,13 @@ For `HASH` partitioned tables, `COALESCE PARTITION` and `ADD PARTITION` are not `EXCHANGE PARTITION` works by swapping a partition and a non-partitioned table, similar to how renaming a table like `RENAME TABLE t1 TO t1_tmp, t2 TO t1, t1_tmp TO t2` works. -- As an example: `ALTER TABLE partitioned_table EXCHANGE PARTITION p1 WITH TABLE non_partitioned_table`, swaps the table `non_partitioned_table` with the partition `p1` in the `partitioned_table` table. +For example, `ALTER TABLE partitioned_table EXCHANGE PARTITION p1 WITH TABLE non_partitioned_table` swaps the `non_partitioned_table` table in the `p1` partition with the `partitioned_table` table. -Please be sure that all rows you are exchanging into the partition are matching the partition definition, or else they will not be found and there may be other issues. +Ensure that all rows that you are exchanging into the partition match the partition definition; otherwise, these rows will not be found and cause unexpected issues. > **Warning:** > -> - `EXCHANGE PARTITION` is an experimental feature. It is not yet recommended to use it in a production environment. To enable it, set the `tidb_enable_exchange_partition` system variable to `ON`. +> `EXCHANGE PARTITION` is an experimental feature. It is not recommended to use it in a production environment. To enable it, set the `tidb_enable_exchange_partition` system variable to `ON`. ### Range partition management