-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schemadiff: support for RangeRotationStrategy diff hint #10131
schemadiff: support for RangeRotationStrategy diff hint #10131
Conversation
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
To support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me! What might be worth noting is that, we are expanding the parsing support for partition definitions (#10127 ) along with sub partitions (soon to follow).
Oh wonderful! Do you think we might be able to then have:
? |
Yes! Most definitely. We can work on that before subpartitions, since I see you need it for completing this work! |
@GuptaManan100 thank you! There is no urgency for this work. |
@shlomi-noach I checked, and apparently we already have parsing support for |
With this we augmented the partition definition, which also added that additional parsing to |
@GuptaManan100 ahhh, that's right! Now I see it. Thank you. |
Tracking issue: #10203 |
Description
Diffing partitions is a complex topic. There can be scenarios where a change of partitioning scheme required an entire rebuild of the table (e.g. change of number of
HASH
partitions), and cases where optimally one could get by with only modifying some of the partitions (e.g.COALESCE
two partitions into one).Normally, when we see a diff of partitions, we just invoke an
ALTER TABLE... PARTITION BY...
with the entire new partitioning scheme. The idea? Even aCOALESCE
for two partitions out of200
is a blocking schema change. As we push forward Online DDL, we are opinionated that it's better to rebuild the entire table, online, than just2
partitions out of200
, in a blocking operation.However, there are exceptions to this.
A common partitioning scheme that does not require blocking: rotation of range partitioning. The classic example is, say, partitioning by day, such that every day we add a new partition; and possibly every day we also purge an old partition.
We could be adding a bunch of partitions at a time, or drop a bunch of partitions at a time.
Adding new partitions is super cheap, and dropping old partitions can be cheap or expensive, depending on the size of dropped partition and version of MySQL.
In this PR
schemadiff
identifies a rotating range partitioning scheme: two tables that are partitioned byRANGE
, share exactly one consecutive non-empty sequence of partitions (i.e., the two tables have some partitions in common), and possibly:As of this PR
schemadiff
supports aRangeRotationStrategy
, of the following values:RangeRotationFullSpec
: generate a full partitioning spec, meaning do not optimize for partition rotation; this behavior is the same as before this PRRangeRotationIgnore
: consider this as a non-diff. This is similar in concept to ignoring anAUTO_INCREMENT
increase.RangeRotationStatements
NOT YET IMPLEMENTED. Will throw an error. Once implemented, will return the properDROP PARTITION ...
andADD PARTITION ...
statements that perform the rotation.Checklist