SPQR PostgreSQL Sharding Router Review
docs.pg-sharding.tech · checked 11 Oct 2026
Open-source PostgreSQL sharding router for self-hosted deployments.
How it plugs in
Signal on Database Proxy Software6.3#7 of 31
SPQR is a stateless router that scales PostgreSQL horizontally by distributing data across shards. Its router directs requests with single-column or multi-column sharding keys and can move data to rebalance shards. Clients connect through PostgreSQL’s protocol. SPQR is self-hosted, free, open source, and available with Docker.

Review
In a line
SPQR helps PostgreSQL scale horizontally by dividing data among shards. Its router directs queries to the appropriate shard.
What it does
If a query exposes a usable sharding key, the router maps it to the corresponding key range and shard. A SQL comment can instead supply the key or explicitly select a shard.
Keys may consist of one column or several columns combined. To balance workload, SPQR migrates data between shards and aims to keep transferred ranges smaller, limiting locking impact.
For transactions involving multiple shards, SPQR offers one-phase and two-phase commit. The latter makes the operation atomic across shards and requires max_prepared_transactions to be greater than zero on each shard.
How it connects
SPQR accepts client connections through PostgreSQL’s wire protocol; pgx and JDBC are examples of compatible drivers. An administrative console for the router and coordinator is available through psql.
You can deploy SPQR yourself on Linux using its Docker image and a configuration file. Connection pooling and query routing are included, and PostgreSQL SSL modes shown in the documentation include require and verify-full.
Shards can be hosted on managed PostgreSQL services such as Amazon RDS, Google Cloud SQL, Azure Database, and Yandex Managed PostgreSQL.
Good fit
SPQR is aimed at PostgreSQL developers who prefer not to implement sharding logic in application code. It is a fit for workloads centered on single-shard online transaction processing queries.
The project says it has handled terabytes of data and more than 100K queries per second.
Watch for
Complex queries that span shards, transactions changing multiple shards, and analytical workloads are areas where SPQR is not suitable.
Depending on workload, the FAQ puts the performance decline at roughly 10%–30% versus vanilla PostgreSQL. You also need to operate the deployment yourself and plan how shards and transaction settings will be managed.
Pricing
SPQR costs nothing and is open source. It is distributed under the PostgreSQL Global Development Group License. The plan listed is SPQR, with no paid tier stated.
Verdict
Consider SPQR if your team runs PostgreSQL, needs horizontal scale, and can keep most transactions on one shard. PostgreSQL protocol support, shard options on managed services, Docker deployment, and built-in routing can reduce the need to add sharding code to an application.
Look elsewhere if reporting spans many shards, if multi-shard writes are central to the workload, or if you need SPQR itself to be managed. The reported performance trade-off and self-hosted operations also deserve review before adoption.
Our take
SPQR can help teams distribute PostgreSQL data without building routing rules into every application. Its free, open-source model can suit organizations prepared to run Linux or container deployments and manage shard placement themselves. The fit is weaker for analytics, broad cross-shard searches, or workloads dominated by writes touching several shards. Before choosing it, estimate the effect of its reported 10%–30% performance loss and confirm that your drivers, managed PostgreSQL service, and transaction settings match the design.
- Available at no cost under the PostgreSQL Global Development Group License
- Routes queries with single-column or composite sharding keys
- Supports Docker, Linux, PostgreSQL drivers, and managed PostgreSQL services for shards
- Can rebalance data between shards
- Not suitable for complex queries that cross shards or for OLAP workloads
- Multi-shard transactions add configuration requirements
- FAQ reports a roughly 10%–30% performance drop versus PostgreSQL
- Self-hosted operation is required
- Pick it ifPostgreSQL teams seeking to avoid application-level sharding logic; Single-shard OLTP workloads needing horizontal scale; Teams able to run and manage shard infrastructure
- Skip it ifYour workload depends on complex cross-shard queries or writes spanning multiple shards; You need OLAP-focused processing; You cannot operate a self-hosted PostgreSQL routing layer
Pricing
SPQR is free with an open-source license. The facts list one SPQR plan and no paid tier.
- SPQROpen-source PostgreSQL sharding softwareFree
As github.com lists them, checked 11 Oct 2026.
Questions
What is SPQR?
SPQR is a stateless PostgreSQL router that supports horizontal scaling by sharding data.
How does SPQR choose a shard?
A query’s usable sharding key lets SPQR map the request to its key range and shard. A SQL comment may instead supply the key or designate a shard explicitly.
Which databases and drivers work with SPQR?
SPQR works with PostgreSQL and lists pgx and JDBC as compatible driver examples. Shards may use managed services such as Amazon RDS, Google Cloud SQL, Azure Database, and Yandex Managed PostgreSQL.
Is SPQR free?
Yes. SPQR is available at no cost as open-source software under the PostgreSQL Global Development Group License.
Where can SPQR run?
SPQR is self-hosted on Linux. Docker image and configuration instructions are available.
What workloads should avoid SPQR?
Avoid SPQR for complex queries across shards, transactions that change multiple shards, or OLAP workloads.
Does SPQR support transactions across shards?
SPQR supports both one-phase and two-phase commit. The two-phase mode provides atomicity across shards and requires max_prepared_transactions above zero on every shard.