diff --git a/docs/configuration/router.mdx b/docs/configuration/router.mdx index b25cd31f6..cbf255082 100644 --- a/docs/configuration/router.mdx +++ b/docs/configuration/router.mdx @@ -83,11 +83,13 @@ Map of string to Shard objects. Refer to the `Shard` struct in the [pkg/config/r ## Feature Flags -| Setting | Description | Possible Values | -|--------------------------|-----------------------------------------------|-----------------| -| `maintain_params` | Whether to maintain parameters flag. | `true`, `false` | -| `with_jaeger` | Whether to integrate with Jaeger for tracing. | `true`, `false` | -| `world_shard_fallback` | Whether to enable fallback to world shard. | `true`, `false` | +| Setting | Description | Possible Values | +|-----------------------------------------|-------------------------------------------------|-----------------| +| `maintain_params` | Whether to maintain parameters flag. | `true`, `false` | +| `query_routing.default_route_behaviour` | Whether to explicitly block multishard queries. | `BLOCK`, `` | +| `query_routing.multicast_unroutable_insert_statement` | Whether to send insert statements without a sharding key to all shards. | `true`, `false` | +| `with_jaeger` | Whether to integrate with Jaeger for tracing. | `true`, `false` | +| `world_shard_fallback` | Whether to enable fallback to world shard. | `true`, `false` | ## Mode Settings diff --git a/docs/sharding/console/sql_commands.mdx b/docs/sharding/console/sql_commands.mdx index 11dc690cf..79625bcc0 100644 --- a/docs/sharding/console/sql_commands.mdx +++ b/docs/sharding/console/sql_commands.mdx @@ -8,7 +8,7 @@ Description: 'Create distributions, key ranges and tables and see cluster info' This command is used to create a new distribution with the specified name. Optionally, you can specify the column types for the distribution using the COLUMN TYPES clause. ```sql -CREATE DISTRIBUTION [COLUMN TYPES types] +CREATE DISTRIBUTION COLUMN TYPES where types is a comma-separated list of column types @@ -23,16 +23,23 @@ This command is used to drop an existing distribution with the specified name. T DROP DISTRIBUTION [CASCADE] ``` -### ALTER DISTRIBUTION +### ALTER DISTRIBUTION ATTACH RELATION -This command is used to alter an existing distribution. You can attach one or more relations to the distribution using the ATTACH RELATION clause, or detach a relation from the distribution using the DETACH RELATION clause. +This command is used to alter an existing distribution. You can attach one or more relations to the distribution using the ATTACH RELATION clause. ```sql -ALTER DISTRIBUTION -[ - ATTACH RELATION [, ...] | - DETACH RELATION -] +ALTER DISTRIBUTION ATTACH RELATION [, ...] +DISTRIBUTION KEY [HASH FUNCTION ] + +where hash_function_name is one of: IDENTITY, MURMUR, CITY +``` + +### ALTER DISTRIBUTION DETACH RELATION + +This command is used to alter an existing distribution. You can detach a relation from the distribution using the DETACH RELATION clause. + +```sql +ALTER DISTRIBUTION DETACH RELATION ``` ### CREATE KEY RANGE diff --git a/docs/welcome/get_started.mdx b/docs/welcome/get_started.mdx index 94f258945..c3da5a4e1 100644 --- a/docs/welcome/get_started.mdx +++ b/docs/welcome/get_started.mdx @@ -93,4 +93,62 @@ CREATE KEY RANGE krid2 FROM 1000 ROUTE TO shard2 FOR DISTRIBUTION ds1; (1 row) ``` -Here we go! You can play with some SELECTs or INSERTs. \ No newline at end of file +Here we go! You can play with some SELECTs or INSERTs. + +### Connect to SPQR router + +Now we can connect to proxy a.k.a. router and play with it: + +```bash +➜ psql "host=localhost sslmode=disable user=demo dbname=demo port=6432" +psql (13.3, server 9.6.22) +Type "help" for help. + +demo=> CREATE TABLE orders ( + id SERIAL NOT NULL PRIMARY KEY, + customer_id INT, + order_date DATE +); +NOTICE: send query to shard(s) : shard01,shard02 +CREATE TABLE + +demo=> CREATE TABLE items ( + id SERIAL NOT NULL PRIMARY KEY, + order_id SERIAL NOT NULL PRIMARY KEY, + name VARCHAR, +); +NOTICE: send query to shard(s) : shard01,shard02 +CREATE TABLE + +demo=> BEGIN; +BEGIN +demo=> INSERT INTO orders (id, customer_id, order_data) VALUES (777, 123456, '2024-01-08'); +NOTICE: send query to shard(s) : shard01 +INSERT 0 1 +demo=> INSERT INTO items (id, order_id, name) VALUES (1, 777, 'elephant'); +INSERT 0 1 +demo=> COMMIT; +COMMIT +``` + +> NOTICE messages are disabled by default, specify `show_notice_messages` setting in the router config to enable them + +You could check now that each shard has only one record: + +```bash +demo=> SELECT * FROM orders WHERE id = 777; +NOTICE: send query to shard(s) : shard01 + id | customer_id | order_data +------+-------------+-------------- + 777 | 123456 | '2024-01-08' +(1 row) + +SPQR can handle such queries as `SELECT * FROM table` but we don't recommend using it. This feature is implemented in a non-transactional way. + +```bash +demo=> SELECT * FROM orders WHERE id = 777; +NOTICE: send query to shard(s) : shard01 + id | customer_id | order_data +------+-------------+-------------- + 777 | 123456 | '2024-01-08' +(1 row) \ No newline at end of file diff --git a/docs/welcome/index.mdx b/docs/welcome/index.mdx index 180b8d578..7357a90a2 100644 --- a/docs/welcome/index.mdx +++ b/docs/welcome/index.mdx @@ -32,7 +32,7 @@ SPQR is a good fit for: Learn more how SPQR works under the hood