From c84dd48b20bf3d40f807870620f7a1fc7b4af048 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 e89cf5e4ba691..e5b6657a8665a 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 8fa4d24eb45ecc5546c539187fed2791a9e9cceb 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 e5b6657a8665a..b6c1915e94623 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 e2ccfd2b5a7cd2e05c43f6e3e9c29ec78ad9f767 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 b6c1915e94623..c0a90b78b16ea 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 c812e414f1318801b48886d57d52798e366ce992 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 c0a90b78b16ea..c5a2493befb70 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 5a2ddba9a22cdb2be19e20f6aeb7129cee748263 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 c5a2493befb70..3e1072dabd63b 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 ba93644537db02f054661eaf3036f63c8811503b 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 3e1072dabd63b..db1ad9dd702ca 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 4302aa5183ef4b7bd91ac7cccd58f33528d588e9 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 db1ad9dd702ca..096f00e1d5e80 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 38f6bc16b3b70895c04528e9addc9b4880a2d4cc 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 096f00e1d5e80..23b11a931dcc4 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