pgrundev / pgx
git clone https://github.com/pgrundev/pgx.git
PGX — Lightweight Postgres for AI agents. Written in Rust. Thousands of isolated databases in one runtime. 🐘
+70
stars, 24h · #205
+~490
stars, 7 days · #250
+168
stars, 30 days · #3,116
291
★ total · +490% this week
19
forks · 6 open issues
Star history (as recorded here)
LanguageRust
LicenseAGPL-3.0
Created2026-10-08 (13d ago)
Last pushtoday
Watchers0
OwnerOrganization
GitHub topics
agentsai-infrastructureai-infrastructure-developmentai-infrastructure-softwaredatabaseopen-sourcepostgrespostgresqlrustrust-lang
Links
- GitHub: github.com/pgrundev/pgx
- Homepage: https://pgx.dev
- Releases · Issues · Hacker News mentions
README excerpt
PGX PGX. Postgres for agents. 🐘 One runtime. Thousands of Postgres databases. [code] No Docker required · Native Mac & Linux · Automatic cleanup Open source · Free · Beta · Built for disposable development databases PGX is a database runtime for short-lived Postgres databases: agent sandboxes, CI and per-PR databases, test and preview environments. One PGX process holds many isolated databases. Each costs tens of kilobytes of memory while idle, is created in milliseconds from a sealed template, and is backed, on a copy-on-write storage backend such as ZFS, by a clone that starts at a few megabytes whatever the template's size (on a filesystem without block cloning a branch is a full copy). PGX speaks the Postgres wire protocol and SQL dialect. Rails, Django, Prisma, SQLAlchemy and node-postgres run their full migrate → test → schema-change lifecycles on it unchanged. PGX is the database engine behind PGRun branches. > A database should be cheap enough to allocate like an object, not > provision like a server. ## Why PGX Agent workflows, test suites, CI jobs and preview environments create databases constantly and throw them away minutes or hours later. Giving each one its own PostgreSQL server costs a process, tens of megabytes and a cold start every time. Traditional PostgreSQL is built to keep one database running for years; PGX is built to create one in milliseconds, use it briefly and delete it. Instead of [code] PGX runs [code] Immutable state is shared. Each database pays mainly for what makes it different. ## At a glance [code] These describe measured configurations and workloads, not a claim that PGX is faster than PostgreSQL in general. The detail and the scripts are under Benchmarks. ## Disposable Postgres PGX is built around a different database lifecycle: [code] A database is created from a sealed template without copying it. On Linux, ZFS block cloning lets a branch share every unchanged block with its template, so a branch of a 10 GB database is ready in under a second and starts at about 14 MB of its own storage. ## Built for agents A coding agent's database workload looks like this, and many agents do it at once: [code] PGX optimizes for that lifecycle rather than for a long-running production primary. Every agent, every pull request and every test run can have its own real Postgres-compatible database. ## Benchmarks Measured on a 4 vCPU / 8 GB / $8.50-a-month VPS with ZFS block cloning. The load generator ran on the same CPUs, so these are architecture numbers, not capacity limits. Every figure has a script and a committed raw result (`benchmarks/pgx/linux/README.md`). ### Density | | PGX | |---|---| | 1000 idle databases in one runtime | **128–155 MB** in total | | 1000 databases, each queried once | **213 MB** | | Per idle database | ~70 KB untouched, ~128 KB once queried | | 1000 databases with 100 active | 283 MB | | Idle CPU with 1000 databases | 0.33–0.43 % of one core | For comparison, one idle PostgreSQ