-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add domiciling doc with PLACEMENT RESTRICTED
Fixes DOC-1178 Fixes DOC-1242 Summary of changes: - Update 'Data Domiciling' page with some basic info, that explains how to accomplish domiciling with the 'ALTER DATABASE ... PLACEMENT RESTRICTED' feature, and how to check that replicas are where they are supposed to be using the Replication Reports.
- Loading branch information
1 parent
c7b45e5
commit 87dd1a1
Showing
6 changed files
with
349 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Because the data in `promo_codes` is not updated frequently (a.k.a., "read-mostly"), and needs to be available from any region, the right table locality is [`GLOBAL`](multiregion-overview.html#global-tables). | ||
|
||
{% include copy-clipboard.html %} | ||
~~~ sql | ||
ALTER TABLE promo_codes SET locality GLOBAL; | ||
~~~ | ||
|
||
Next, alter the `user_promo_codes` table to have a foreign key into the global `promo_codes` table. This will enable fast reads of the `promo_codes.code` column from any region in the cluster. | ||
|
||
{% include copy-clipboard.html %} | ||
~~~ sql | ||
ALTER TABLE user_promo_codes | ||
ADD CONSTRAINT user_promo_codes_code_fk | ||
FOREIGN KEY (code) | ||
REFERENCES promo_codes (code) | ||
ON UPDATE CASCADE; | ||
~~~ |
103 changes: 103 additions & 0 deletions
103
_includes/v21.2/sql/multiregion-movr-regional-by-row.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
All of the tables except `promo_codes` contain rows which are partitioned by region, and updated very frequently. For these tables, the right table locality for optimizing access to their data is [`REGIONAL BY ROW`](multiregion-overview.html#regional-by-row-tables). | ||
|
||
Apply this table locality to the remaining tables. These statements use a `CASE` statement to put data for a given city in the right region and can take around 1 minute to complete for each table. | ||
|
||
- `rides` | ||
|
||
{% include copy-clipboard.html %} | ||
~~~ sql | ||
ALTER TABLE rides ADD COLUMN region crdb_internal_region AS ( | ||
CASE WHEN city = 'amsterdam' THEN 'europe-west1' | ||
WHEN city = 'paris' THEN 'europe-west1' | ||
WHEN city = 'rome' THEN 'europe-west1' | ||
WHEN city = 'new york' THEN 'us-east1' | ||
WHEN city = 'boston' THEN 'us-east1' | ||
WHEN city = 'washington dc' THEN 'us-east1' | ||
WHEN city = 'san francisco' THEN 'us-west1' | ||
WHEN city = 'seattle' THEN 'us-west1' | ||
WHEN city = 'los angeles' THEN 'us-west1' | ||
END | ||
) STORED; | ||
ALTER TABLE rides ALTER COLUMN REGION SET NOT NULL; | ||
ALTER TABLE rides SET LOCALITY REGIONAL BY ROW AS "region"; | ||
~~~ | ||
|
||
- `user_promo_codes` | ||
|
||
{% include copy-clipboard.html %} | ||
~~~ sql | ||
ALTER TABLE user_promo_codes ADD COLUMN region crdb_internal_region AS ( | ||
CASE WHEN city = 'amsterdam' THEN 'europe-west1' | ||
WHEN city = 'paris' THEN 'europe-west1' | ||
WHEN city = 'rome' THEN 'europe-west1' | ||
WHEN city = 'new york' THEN 'us-east1' | ||
WHEN city = 'boston' THEN 'us-east1' | ||
WHEN city = 'washington dc' THEN 'us-east1' | ||
WHEN city = 'san francisco' THEN 'us-west1' | ||
WHEN city = 'seattle' THEN 'us-west1' | ||
WHEN city = 'los angeles' THEN 'us-west1' | ||
END | ||
) STORED; | ||
ALTER TABLE user_promo_codes ALTER COLUMN REGION SET NOT NULL; | ||
ALTER TABLE user_promo_codes SET LOCALITY REGIONAL BY ROW AS "region"; | ||
~~~ | ||
|
||
- `users` | ||
|
||
{% include copy-clipboard.html %} | ||
~~~ sql | ||
ALTER TABLE users ADD COLUMN region crdb_internal_region AS ( | ||
CASE WHEN city = 'amsterdam' THEN 'europe-west1' | ||
WHEN city = 'paris' THEN 'europe-west1' | ||
WHEN city = 'rome' THEN 'europe-west1' | ||
WHEN city = 'new york' THEN 'us-east1' | ||
WHEN city = 'boston' THEN 'us-east1' | ||
WHEN city = 'washington dc' THEN 'us-east1' | ||
WHEN city = 'san francisco' THEN 'us-west1' | ||
WHEN city = 'seattle' THEN 'us-west1' | ||
WHEN city = 'los angeles' THEN 'us-west1' | ||
END | ||
) STORED; | ||
ALTER TABLE users ALTER COLUMN REGION SET NOT NULL; | ||
ALTER TABLE users SET LOCALITY REGIONAL BY ROW AS "region"; | ||
~~~ | ||
|
||
- `vehicle_location_histories` | ||
|
||
{% include copy-clipboard.html %} | ||
~~~ sql | ||
ALTER TABLE vehicle_location_histories ADD COLUMN region crdb_internal_region AS ( | ||
CASE WHEN city = 'amsterdam' THEN 'europe-west1' | ||
WHEN city = 'paris' THEN 'europe-west1' | ||
WHEN city = 'rome' THEN 'europe-west1' | ||
WHEN city = 'new york' THEN 'us-east1' | ||
WHEN city = 'boston' THEN 'us-east1' | ||
WHEN city = 'washington dc' THEN 'us-east1' | ||
WHEN city = 'san francisco' THEN 'us-west1' | ||
WHEN city = 'seattle' THEN 'us-west1' | ||
WHEN city = 'los angeles' THEN 'us-west1' | ||
END | ||
) STORED; | ||
ALTER TABLE vehicle_location_histories ALTER COLUMN REGION SET NOT NULL; | ||
ALTER TABLE vehicle_location_histories SET LOCALITY REGIONAL BY ROW AS "region"; | ||
~~~ | ||
|
||
- `vehicles` | ||
|
||
{% include copy-clipboard.html %} | ||
~~~ sql | ||
ALTER TABLE vehicles ADD COLUMN region crdb_internal_region AS ( | ||
CASE WHEN city = 'amsterdam' THEN 'europe-west1' | ||
WHEN city = 'paris' THEN 'europe-west1' | ||
WHEN city = 'rome' THEN 'europe-west1' | ||
WHEN city = 'new york' THEN 'us-east1' | ||
WHEN city = 'boston' THEN 'us-east1' | ||
WHEN city = 'washington dc' THEN 'us-east1' | ||
WHEN city = 'san francisco' THEN 'us-west1' | ||
WHEN city = 'seattle' THEN 'us-west1' | ||
WHEN city = 'los angeles' THEN 'us-west1' | ||
END | ||
) STORED; | ||
ALTER TABLE vehicles ALTER COLUMN REGION SET NOT NULL; | ||
ALTER TABLE vehicles SET LOCALITY REGIONAL BY ROW AS "region"; | ||
~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.