pgdogdev /pgdog

PostgreSQL connection pooler, load balancer and database sharder.

★ 5,614⑂ 314👁 22⑃ 1,479● 521▤ 64
RustAGPL-3.0Created 2024-12-27pgdog.dev
下载:v0.1.65v0.1.65 ↓0.1.652026-11-12
+0
日增长
5,614
stars
314
forks
22
watchers
1,479
prs
521
issues
64
releases

README

PgDog is an open source proxy for scaling PostgreSQL. It supports connection pooling, load balancing queries and sharding entire databases. Written in Rust, PgDog is fast, secure and can manage thousands of connections on commodity hardware.

 Documentation

&128216; PgDog documentation can be found here. Any questions? Chat with us on Discord.

 Enterprise edition

&127970; Enterprise edition (EE) documentation is available here. Changelog is available here.

 Quick start

 Kubernetes

Helm chart is here. To install it, run:

bash
helm repo add pgdogdev https://helm.pgdog.dev
helm install pgdog pgdogdev/pgdog


 AWS

If you're using AWS RDS, you can deploy PgDog using one of two supported methods:

1. Helm chart with EKS, or a self-hosted Kubernetes cluster
2. Terraform module to deploy PgDog on ECS

 Try in Docker

You can try PgDog quickly using Docker. Install Docker Compose and run:


docker-compose up


Once started, you can connect to PgDog with psql or any other PostgreSQL client:


PGPASSWORD=postgres psql -h 127.0.0.1 -p 6432 -U postgres


The demo comes with 3 shards and 2 sharded tables:

sql
INSERT INTO users (id, email) VALUES (1, '[email protected]');
INSERT INTO payments (id, user_id, amount) VALUES (1, 1, 100.0);

SELECT  FROM users WHERE id = 1;
SELECT  FROM payments WHERE user_id = 1;


 Features

&128216; Configuration

All PgDog features are configurable and can be turned on and off. PgDog requires 2 configuration files to operate:

1. pgdog.toml: hosts, sharding configuration, and other settings
2. users.toml: usernames and passwords

 Example

Most options have reasonable defaults, so a basic configuration for a single user
and database running on the same machine is pretty short:

pgdog.toml

toml
[general]
port = 6432
default_pool_size = 10

[[databases]]
name = "pgdog"
host = "127.0.0.1"


users.toml

toml
[[users]]
name = "alice"
database = "pgdog"
password = "hunter2"


If a database in pgdog.toml doesn't have a user in users.toml, the connection pool for that database will not be created and users won't be able to connect.

If you'd like to try it out locally, create the database and user like so:

sql
CREATE DATABASE pgdog;
CREATE USER pgdog PASSWORD 'pgdog' LOGIN;


 Transaction pooling

&128216; Transactions

Like PgBouncer, PgDog supports transaction (and session) pooling, allowing
thousands of clients to use just a few PostgreSQL server connections.

Unlike PgBouncer, PgDog can parse and handle SET statements and startup options, ensuring session state is set correctly when sharing server connections between clients with different parameters.

PgDog also has more advanced connection recovery options, like automatic abandoned transaction rollbacks and connection re-synchronization to avoid churning server connections during an application crash.

 Load balancer

&128216; Load balancer

PgDog is an application layer (OSI Level 7) load balancer for PostgreSQL. It understands the Postgres protocol, can proxy multiple re

Top issues

Discussions

Latest release

v0.1.65 v0.1.65 2026-11-12
Peformance
- More performance improvements in the hot path, reducing memory allocations, CPU instructions, and mutex contention required to serve a query @jkaczman 
- Use unnest() in cross-shard subqueries instead of injecting raw values, producing a massive improvement in performance @jkaczman 

 Features
- Cross-shard GROUP BY now supports aggregation on columns not specified in the SELECT clause @murex971 
- Add support for cross-shard CTEs @jkaczman 
- Add support for derived tables in subqueries @jkaczman 
- Add support for cross-shard GROUP BY with HAVING clause @murex971 
- Add

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON