Skip to main content
The router knows that some tables have been split into shards. If possible, the router tries to determine on the first transaction statement to which shard this transaction should be sent. SPQR supports both single-column and composite (multi-column) sharding keys.

Query Routing

When a query arrives, the router extracts the sharding key from the query and determines which key range (and thus which shard) should handle it.

Explicit Sharding Key

You can explicitly specify a sharding key in a SQL comment when the router cannot determine it automatically:
For composite sharding keys, specify all key values separated by commas:

Explicit Shard Selection

You can also force a query to execute on a specific shard: