[MDEV-22165] CONVERT TABLE: move in partition from existing table Created: 2020-04-06 Updated: 2024-01-03 Resolved: 2021-10-26 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Partitioning |
| Fix Version/s: | 10.7.1 |
| Type: | Task | Priority: | Critical |
| Reporter: | Michael Widenius | Assignee: | Aleksey Midenkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
Adding a new table to a partitioned table is now quite cumbersome: ALTER TABLE archive ADD PARTITION (PARTITION p1 VALUES LESS THAN (200)); It would be nice to be able to do this in one step: The operation crash safety must be protected by DDL logging. |
| Comments |
| Comment by Dmitry Shulga [ 2021-08-02 ] | |||
|
Just to be clear, the statement like the following one | |||
| Comment by Sergei Golubchik [ 2021-08-02 ] | |||
|
this is a replacement for EXCHANGE PARTITION, so it should not copy the data, but simply rename the table to become a partition. If you think ADD PARTITION is confusing, use IMPORT PARTITION for example. | |||
| Comment by Aleksey Midenkov [ 2021-08-03 ] | |||
|
Then | |||
| Comment by Sergei Golubchik [ 2021-08-03 ] | |||
|
Yes, IMPORT/EXPORT look much better than ADD/EXTRACT | |||
| Comment by Aleksey Midenkov [ 2021-08-05 ] | |||
|
OTOH classical meaning of IMPORT/EXPORT implies keeping the original data. If we move data instead that is not quite user-intuitive for these terms. We can be straightforward for what we do by using RENAME keyword: ALTER TABLE archive RENAME PARTITION p1 TO TABLE tp1; I believe there is still no fast partition rename in MySQL/MariaDB, so we could make that as a bonus: ALTER TABLE archive RENAME PARTITION p1 TO p11; Btw, the last syntax is supported by Oracle. | |||
| Comment by Dmitry Shulga [ 2021-08-08 ] | |||
|
I support the Aleksey's opinion that meaning of IMPORT/EXPORT implies keeping the original data. On the other hand, I believe that the new syntax for adding a partition by virtue of moving a separate table to table's partition should be aligned with current syntax of ALTER TABLE in respect of adding partitions. Therefore from my point of view the following syntax would be more clear in expressing the idea of moving data from external table to table's partition: For the sake of uniformity, the keyword MIGRATE could also be used in the ALTER statement for moving a partition to an external table: | |||
| Comment by Aleksey Midenkov [ 2021-08-10 ] | |||
|
Using the MIGRATE keyword looks like a nice idea. Keeping ADD PARTITION syntax compatibility is something that I also thought of. The downside of that is kind of longer syntax: two sequential PARTITION keywords. I hope we can make PARTITION inside the brackets optional. | |||
| Comment by Federico Razzoli [ 2021-08-10 ] | |||
|
What happens if the two tables are different in one of these aspects?
Indexes differences are not unlikely, in my opinion. What happens if the original table has triggers? | |||
| Comment by Sergei Golubchik [ 2021-08-13 ] | |||
|
Somehow I don't see how the original
is worse or more confusing than
if anything, the former is shorter and only uses familiar keywords, it doesn't introduce a new keyword into the grammar | |||
| Comment by Sergei Golubchik [ 2021-08-17 ] | |||
|
f_razzoli, this feature introduces a convenience command to replace the following sql script:
it does not allow to do anything that wasn't possible before and it should generally behave exactly as the script above. Also in regards to indexes, invisible columns, constraints, etc. | |||
| Comment by Aleksey Midenkov [ 2021-09-10 ] | |||
|
Please review bb-10.7-midenok-MDEV-22165 | |||
| Comment by Sergei Golubchik [ 2021-09-13 ] | |||
|
pushed together with |