-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: facilitate applying zone configs to same-named partitions #39357
Comments
cc @andreimatei bc he was interested |
I think a key thing here is to somehow tie together all the "north_america" partitions of different tables and have all of them point to a single "zone config". As it stands, zone configs are defined by a start and end key, so there's no such thing as different tables or partitions pointing to the same zone config. But there should be. |
`ALTER ALL PARTITIONS ... OF TABLE` applies a zone configuration to all the partitions of a table and its indexes which have the specified name. Refers cockroachdb#39357 Release note (sql change): Added the `ALTER ALL PARTITIONS ... OF TABLE` command, which allows applying a zone configuration to all the partitions of a table and its indexes with the specified name.
`ALTER PARTITION ... OF INDEX` now allows a user to specify all indexes of a table via `tbl@*` syntax. This means that every partition with the specified name across all of a table's indexes should be affected. Refers cockroachdb#39357 Release note (sql change): The `ALTER PARTITION` statement now supports applying a zone configuration to all the partitions of a table and its indexes that share the same partition name. The syntax for this is `ALTER PARTITION <partition name> OF INDEX <table name>@*`.
`ALTER PARTITION ... OF INDEX` now allows a user to specify all indexes of a table via `tbl@*` syntax. This means that every partition with the specified name across all of a table's indexes should be affected. Refers cockroachdb#39357 Release note (sql change): The `ALTER PARTITION` statement now supports applying a zone configuration to all the partitions of a table and its indexes that share the same partition name. The syntax for this is `ALTER PARTITION <partition name> OF INDEX <table name>@*`.
39750: sql: support wildcard in ALTER PARTITION OF INDEX r=solongordon a=solongordon sql: support wildcard in ALTER PARTITION OF INDEX `ALTER PARTITION ... OF INDEX` now allows a user to specify all indexes of a table via `tbl@*` syntax. This means that every partition with the specified name across all of a table's indexes should be affected. Refers #39357 Release note (sql change): The `ALTER PARTITION` statement now supports applying a zone configuration to all the partitions of a table and its indexes that share the same partition name. The syntax for this is `ALTER PARTITION <partition name> OF INDEX <table name>@*`. Co-authored-by: Solon Gordon <solon@cockroachlabs.com>
@solongordon so with #39750 this now applies to all indexes. Where we thinking this could apply to the entire table + indexes in this issue with another pr? or is that now a separate issue? |
The terminology is slightly confusing but "all indexes" includes the primary index, so this already applies to the entire table plus indexes. I didn't close this issue because this doesn't address @andreimatei's concerns about how to tie together analogous partitions across multiple tables, but that is a broader issue so perhaps it could use a fresh issue. |
Ah I see. I was able to do that via: ALTER TABLE rides PARTITION BY LIST (city) ( PARTITION new_york VALUES IN ('new york'), PARTITION chicago VALUES IN ('chicago'), PARTITION seattle VALUES IN ('seattle') );
ALTER INDEX rides_auto_index_fk_city_ref_users PARTITION BY LIST (city) ( PARTITION new_york VALUES IN ('new york'), PARTITION chicago VALUES IN ('chicago'), PARTITION seattle VALUES IN ('seattle') );
ALTER INDEX rides_auto_index_fk_vehicle_city_ref_vehicles PARTITION BY LIST (vehicle_city) ( PARTITION new_york VALUES IN ('new york'), PARTITION chicago VALUES IN ('chicago'), PARTITION seattle VALUES IN ('seattle') ); Then: show partitions from table rides;
database_name | table_name | partition_name | parent_partition | column_names | index_name | partition_value | zone_config
+---------------+------------+----------------+------------------+--------------+-----------------------------------------------------+-----------------+-------------+
movr | rides | new_york | NULL | city | rides@primary | ('new york') | NULL
movr | rides | chicago | NULL | city | rides@primary | ('chicago') | NULL
movr | rides | seattle | NULL | city | rides@primary | ('seattle') | NULL
movr | rides | new_york | NULL | city | rides@rides_auto_index_fk_city_ref_users | ('new york') | NULL
movr | rides | chicago | NULL | city | rides@rides_auto_index_fk_city_ref_users | ('chicago') | NULL
movr | rides | seattle | NULL | city | rides@rides_auto_index_fk_city_ref_users | ('seattle') | NULL
movr | rides | new_york | NULL | vehicle_city | rides@rides_auto_index_fk_vehicle_city_ref_vehicles | ('new york') | NULL
movr | rides | chicago | NULL | vehicle_city | rides@rides_auto_index_fk_vehicle_city_ref_vehicles | ('chicago') | NULL
movr | rides | seattle | NULL | vehicle_city | rides@rides_auto_index_fk_vehicle_city_ref_vehicles | ('seattle') | NULL
(9 rows) Using the new command: ALTER PARTITION new_york OF INDEX movr.rides@* CONFIGURE ZONE USING constraints='[+region=us-east,+az=1]'; ALTER PARTITION chicago OF INDEX rides@* CONFIGURE ZONE USING constraints='[+region=us-central,+az=1]'; ALTER PARTITION seattle OF INDEX movr.rides@* CONFIGURE ZONE USING constraints='[+region=us-west,+az=2]'; And finally we can see that it works:
I think we should close this issue as addressed and open a new one on @andreimatei 's idea. Does that work for you? |
Created #40703 to track @andreimatei's suggestion. |
Once #20880 is closed, it will be possible to use the same name for related partitions on a table and its indexes. Then it would be great to make it easy for users to apply a zone config to all partitions with the same name in a single statement. We could make this the default behavior for
ALTER PARTITION north_america OF TABLE ...
. Or we could make the syntax more explicit, likeALTER ALL PARTITIONS north_america OF TABLE ...
.The text was updated successfully, but these errors were encountered: