SPQR
What it is
SPQR is a self-hosted, open-source query router for scaling PostgreSQL through sharding. It can read a sharding key from a query and route it to a suitable key range and shard when possible; keys may use one column or several. SQL comments can also specify a key or direct a query to a shard. Applications connect using the PostgreSQL protocol, and administrators can use router and coordinator consoles through psql. SPQR supports one-phase and two-phase commit; the two-phase option provides atomicity across shards and requires max_prepared_transactions above zero on every shard. It can move data between shards to balance workload, and its documentation describes Docker and configuration-file deployment. The project reports handling terabytes of data and more than 100,000 queries per second. It works with managed PostgreSQL services and names pgx and JDBC as driver examples. SPQR is free under the PostgreSQL Global Development Group License. Its FAQ cautions against complex cross-shard queries, multi-shard modifying transactions, and OLAP workloads, and reports a roughly 10–30% performance drop versus vanilla PostgreSQL depending on workload.
For and against
For
- Routes queries using single- or multi-column sharding keys.
- Supports managed PostgreSQL services and self-hosted deployment.
- Includes connection pooling and data balancing.
- Free and open source under the PostgreSQL Global Development Group License.
Against
- Not suited to complex cross-shard or OLAP workloads.
- Multi-shard modifying transactions are not recommended.
- Reported performance drop is roughly 10–30%, depending on workload.
The verdict
SPQR provides PostgreSQL sharding and query routing for workloads that fit its single-shard focus. Review its cross-shard limitations and workload-dependent performance trade-off before adopting it.
Who it suits
SPQR is aimed at PostgreSQL developers who want sharding handled by a router instead of application-level logic, especially for workloads suited to single-shard OLTP queries.
Plans and prices
SPQR
Open-source PostgreSQL sharding software
Read 11 Oct 2026 · github.com
On the record
- Automatic routing
- The router extracts a sharding key from a query and uses it to select the key range and shard when possible.docs.pg-sharding.tech · read 5 Oct 2026
- Data balancing
- SPQR migrates data between shards to balance workload and describes reducing the size of transferred ranges to minimize locking impact.docs.pg-sharding.tech · read 5 Oct 2026
- Deployment
- The getting-started guide provides a Docker image and lists router, admin console, and gRPC API ports as 6432, 7432, and 7000.docs.pg-sharding.tech · read 11 Oct 2026
- Distributed transactions
- SPQR offers one-phase and two-phase commit strategies; two-phase commit provides atomicity across shards and requires max_prepared_transactions greater than zero on every shard.docs.pg-sharding.tech · read 11 Oct 2026
- Integrations
- The FAQ says SPQR works with managed PostgreSQL databases including Yandex Managed PostgreSQL and AWS RDS, and names pgx and JDBC as compatible driver examples.docs.pg-sharding.tech · read 11 Oct 2026
- Intended users
- SPQR is presented as a fit for PostgreSQL developers who want to avoid application-level sharding logic and workloads suited to single-shard OLTP queries.docs.pg-sharding.tech · read 5 Oct 2026
- License
- The source is distributed under the PostgreSQL Global Development Group License.github.com · read 11 Oct 2026
- Limits
- The FAQ says SPQR is not suitable for complex cross-shard queries, transactions that modify multiple shards, or OLAP workloads.docs.pg-sharding.tech · read 11 Oct 2026
- Maker
- The documentation says SPQR was designed by the Data Platform team of Yandex.Cloud.docs.pg-sharding.tech · read 5 Oct 2026
- Managed PostgreSQL
- The product site says SPQR can use managed PostgreSQL services including AWS RDS, Google Cloud SQL, and Azure Database for its shards.pg-sharding.tech · read 5 Oct 2026
- Performance
- The FAQ reports a roughly 10–30% performance drop versus vanilla PostgreSQL depending on workload.docs.pg-sharding.tech · read 11 Oct 2026
- PostgreSQL protocol
- Applications communicate with SPQR using the PostgreSQL protocol, and the router and coordinator have an administrative console accessible through psql.docs.pg-sharding.tech · read 11 Oct 2026
- Product
- SPQR is a production-ready system for horizontally scaling PostgreSQL through sharding.docs.pg-sharding.tech · read 5 Oct 2026
- Routing controls
- Queries can specify a sharding key or explicitly select a shard in a SQL comment.docs.pg-sharding.tech · read 5 Oct 2026
- Scale
- The product site says SPQR has handled terabytes of data and 100K+ queries per second.pg-sharding.tech · read 5 Oct 2026
- Security
- The docs show PostgreSQL connections configured with SSL modes including require and verify-full.docs.pg-sharding.tech · read 11 Oct 2026
- Sharding keys
- The router supports single-column and composite sharding keys and routes queries using the key value.docs.pg-sharding.tech · read 11 Oct 2026
- Support
- The project directs users to its Telegram chat for discussion and GitHub Issues for bug reports or feature requests.github.com · read 11 Oct 2026