CREATE DISTRIBUTION
Creates a sharding distribution with a distribution identifier and key column types. A distribution defines the sharding key type layout used by attached relations and key ranges. Optionally, specify a default shard to route records that do not match any key range. For composite sharding keys (multiple columns), specify multiple types separated by commas. You can append “hash” after a column type to apply hash-based distribution to that column.DROP DISTRIBUTION
Removes a distribution from cluster metadata. Use CASCADE to remove dependent metadata objects (key ranges, attached relations) when required.ALTER DISTRIBUTION ATTACH TABLE
Attaches one or more tables to an existing distribution using the ATTACH TABLE clause. For composite sharding keys, specify multiple column names separated by commas in the DISTRIBUTION KEY clause.CREATE TABLE
This command is a shorthand for ALTER DISTRIBUTION ATTACH TABLE. It creates a table and attaches it to a distribution in a single statement. TheDISTRIBUTED keyword is optional and has no effect on the behavior.
There are two syntax forms for specifying distribution keys:
Parenthesized syntax — column names and optional hash functions are listed inside parentheses:
DISTRIBUTION KEY syntax — uses explicit
DISTRIBUTION KEY clause: CREATE [DISTRIBUTED] TABLE [schema.]<table_name> DISTRIBUTION KEY <keys> [IN <distribution_id> | FOR DISTRIBUTION <distribution_id>]ALTER DISTRIBUTION DETACH TABLE
Detaches a table from the distribution using the DETACH TABLE clause.ALTER DISTRIBUTION ALTER TABLE DISTRIBUTION KEY
Replaces the entire distribution key of an already attached table. This overwrites all column names and hash functions in one shot — it does not patch individual columns. Use this when you need to change the key structure entirely, or to fix expression-based routing entries (whichRENAME DISTRIBUTION COLUMN does not support).
The new key must have the same number of entries as the distribution’s column types. Duplicate column names in the new key are rejected.
ALTER DISTRIBUTION ALTER TABLE SCHEMA
Changes the schema associated with an attached table in the distribution metadata.ALTER DISTRIBUTION RENAME DISTRIBUTION COLUMN
A metadata-only fix that renames a column in the distribution key of an attached table. This does not executeALTER TABLE ... RENAME COLUMN on PostgreSQL — it only updates the column name stored in SPQR’s distribution metadata.
The primary use case is fixing a case mismatch between the column name in SPQR metadata and the actual PostgreSQL column. Because PostgreSQL normalizes unquoted identifiers to lowercase, attaching a table with W_ID when the table column is w_id breaks routing: INSERTs fail and SELECTs scatter to all shards.
For composite (multi-column) distribution keys, call this command once per column that needs renaming.
ALTER DISTRIBUTION ADD DEFAULT SHARD
Adds a default shard to an existing distribution. Records that do not match any key range will be routed to this shard.ALTER DISTRIBUTION DROP DEFAULT SHARD
Removes the default shard from an existing distribution.CREATE REFERENCE TABLE
Creates a reference table — a table replicated across all or specific shards. The optional AUTO INCREMENT clause creates a sequence for the specified columns. If no shards are specified with ON, the table is created on all shards.You may specify initial sequence value with the START keyword.
DROP REFERENCE TABLE
Removes a reference table from SPQR metadata. This does not drop the actual table from the shards.ALTER REFERENCE TABLE STORAGE
Changes the set of shards where a reference table is stored.DROP SEQUENCE
Drops a sequence used for auto-increment columns in reference tables. The optional CASCADE keyword drops dependent objects as well.SYNC REFERENCE TABLE
Synchronizes a reference table to a target shard by copying data from an existing shard that already has the table. This is useful when adding a new shard to the cluster that needs reference table data, or recovering reference table data on a shard after a failure.The table structure must already exist on the destination shard before running this command.
CREATE KEY RANGE
This command is used to create a new key range. Since the key space is an ordered set, it is enough to specify only one end of the range. For composite sharding keys, specify multiple values separated by commas that correspond to each column in the distribution.CREATE KEY RANGES FOR DISTRIBUTION
Automatically creates a set of uniformly distributed key ranges for a distribution. Instead of defining each key range manually, this command inspects the distribution’s column type, splits the whole key space (or an explicitly supplied range) into equal parts, and creates one key range per target shard. The key space is divided evenly across the selected shards, and each resulting key range is assigned to one shard in order. Generated key ranges are named<distributionID>-<index>, where index starts at 0.
By default the command uses the full value range of the distribution column type.
Use the optional BETWEEN clause to bound the generated key ranges to a specific
interval. When no shard selection is given, key ranges are created for all shards.
This command only supports distributions with a single, hashable (numeric) sharding
column. Composite keys and non-hashable types such as varchar or uuid are not
supported; use CREATE KEY RANGE to define those ranges manually.
DROP KEY RANGE
Removes a key range from the cluster. This deletes the key range metadata but does not affect the actual data stored on the shard. Use DROP KEY RANGE ALL to remove all key ranges at once.LOCK KEY RANGE
Locks a key range to prevent concurrent modifications. This is typically used before performing operations like SPLIT or UNITE that require exclusive access to the key range. While a key range is locked, queries routed to it will receive akey range is locked error.
MOVE KEY RANGE
Updates the routing metadata to assign a key range to a different shard. This only changes where new queries for this key range are routed - it does NOT migrate the actual data between shards.REDISTRIBUTE KEY RANGE
Moves a key range to a different shard, including the actual data migration. The operation can be run in check-only mode to validate before applying, and supports batch processing to control the migration pace.SPLIT KEY RANGE
Splits an existing key range into two key ranges at the specified boundary value. The new key range takes the upper portion of the original range (from the split point to the original upper bound), while the source range keeps the lower portion. Both resulting key ranges remain on the same shard. Use REDISTRIBUTE KEY RANGE afterwards to relocate one of them if needed.UNITE KEY RANGE
Merges two adjacent key ranges into a single key range. The left key range absorbs the right key range, extending its upper bound to cover both ranges. The two key ranges must be adjacent (share a boundary) and must route to the same shard. After the operation, the right key range is removed.UNLOCK KEY RANGE
Releases the lock on a key range that was previously locked with LOCK KEY RANGE. After unlocking, queries routed to this key range will resume normal processing.SHOW
Displays cluster metadata, topology, configuration, and runtime status. Valid targets:databases, routers, shards, shards_extended, distributions, key_ranges,
key_ranges_extended, relations, reference_relations, pools, clients,
backend_connections, hosts, version, status, instance, sequences,
users, task_group, task_groups, task_group_ext, task_groups_ext,
move_task, move_tasks, redistribute_tasks, prepared_statements,
time_quantiles, unique_indexes, coordinator_address, is_read_only,
move_stats, errors, startup_finished, two_phase_tx, dcs_storage,
file_settings, tsa_cache.
KILL CLIENT
Terminates a specific client connection by its numeric ID. Use SHOW CLIENTS to find client IDs.KILL BACKEND
Cancels a backend (shard) connection by its numeric ID. Use SHOW BACKEND_CONNECTIONS to find backend IDs.INVALIDATE CACHE
Invalidates the router’s schema cache, forcing it to be rebuilt on the next query.INVALIDATE BACKENDS
Marks all backend connections as stale, causing them to be re-established.INVALIDATE STALE CLIENTS
Identifies clients with dead TCP connections and signals them to close.REGISTER ROUTER
Registers a router with the SPQR coordinator. When a router is registered, the coordinator becomes aware of it and can manage it as part of the cluster. After registration, the coordinator automatically synchronizes metadata (shards, key ranges, distributions) to the router.The router ID must be unique across all registered routers.
The address must be unique across all registered routers.
The router must be reachable at the specified address (a ping check is performed).
After registration, metadata is automatically synchronized to the router via gRPC.