From 2960a3ac13aaff8887bd849ed9e9861d43ed2259 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 e32cbce093358..c7cbea5e878cd 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -579,7 +579,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 25c846810e3d9050f6870b4130f6c119dffe25c2 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 c7cbea5e878cd..4456fba50d66b 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -579,8 +579,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 82dcbda04354c1813571dcec6177e29fda36cbca 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 4456fba50d66b..f74312e541e54 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -579,7 +579,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 7ee407b76c542b689f1ce75ae1ebcde459e92752 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 f74312e541e54..2958fa75b95b5 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -585,11 +585,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 12cea6d7f711ba4cf9e0ad21c75beaf21cbd27a2 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 2958fa75b95b5..9ff4e6436970e 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -581,17 +581,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 cefa29a8d1e2a70b166aa9a5a37b96531ed58753 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 9ff4e6436970e..54f9b78364bff 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -581,19 +581,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 fe9fbe9b7eee2b2e32cf6aee2dfae75c30e53ebe 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 54f9b78364bff..6a7619e299b2c 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -581,7 +581,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 2ca3928f2b1cc5a1e581654405122b78dd609564 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 6a7619e299b2c..5d9b28c9873fc 100644 --- a/partitioned-table.md +++ b/partitioned-table.md @@ -587,13 +587,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