pgrust
A Rust rewrite of Postgres that's faster than Postgres and ClickHouse.
Try pgrust in your browser → | Discord | Updates | Issues
New: Video of Michael's talk at PlanetScale on pgrust — and the slides.
pgrust is a re-implementation of Postgres meant to show what Postgres would look like if it was built in 2026. It is wire compatible and even SQL dialect compatible with Postgres. It passes all 46,066 tests in Postgres' regression suite. For the story of why we're building it, see pgrust: rebuilding Postgres in Rust with AI.
Every line is Rust, written to match the behavior of the C implementation. Rust makes it easy to re-architect several core Postgres pieces. pgrust has:
- A new vectorized push-based, JIT compiled executor
- A thread based concurrency model
- A query scheduler designed to keep any individual query from taking down your database
- A built-in OOM killer that gives pgrust control of what happens when you're running low on memory, greatly reducing the chance of your whole DB being taken down by the OS OOM killer
and many other really awesome pieces. The scheduler and the OOM killer go after two of the four horsemen behind thousands of Postgres outages.
Status
We don't recommend running pgrust in production (yet), but we are successfully running it ourselves internally. Keep Postgres as the source of truth for data you can't afford to lose.
pgrust currently passes the Postgres regression suite. It's faster than Postgres and ClickHouse, but it still has a lot of bugs. Our #1 priority right now is testing and reliability.
If you need production ready Postgres today, use Postgres.
Existing PostgreSQL extensions do not work. There is no stable extension ABI in pgrust yet. Some bundled contrib modules are ported, but PL/Python, PL/Perl, and PL/Tcl are not.
pgrust is specifically tuned for Graviton4 and the JIT compiler only targets Graviton4. pgrust will still work on other platforms, but will not have similar performance.
Performance
Measured on c8g.4xlarge (AWS Graviton4) against PostgreSQL 18.3.
On the ClickBench combined score, pgrust scored 18.5% faster than ClickHouse and hundreds of times faster than PostgreSQL. This was using pgrcolumnar, pgrust's builtin columnar layout.
On sysbench-oltp, pgrust achieved 30% higher throughput than Postgres 18.3 on read-only workloads at 300GB scale.
For a code-level walkthrough of one part of that speedup, read Rebuilding Postgres for 300x faster analytics: batching, operator fusion, and SIMD.
These runs were reviewed independently by Greg Smith, author of PostgreSQL 9.0 High Performance.
Two honest caveats. We had previously reported that pgrust was over 50%
faster than Postgres. On Kubernetes we measure a larger OLTP gap, 50-60%
rather than 30%, and we have not isolated why the same binaries behave
differently there than on bare EC2, so we quote the lower number. Second, the
binaries we publish are generic for their architecture. The benchmark numbers
come from builds tuned for Graviton4 (-Ctarget-cpu=neoverse-v2), so you
will not reproduce them exactly from a download.
Benchmarks and durability settings are unchanged from a default install:
fsync is on. The harnesses are in benchmarks/ so you can
run them yourself.
Writing
- How AI Changes the Economics of JIT Compilers: building a copy-and-patch ARM64 JIT in Rust.
- Rebuilding Postgres for 300x faster analytics: batching, operator fusion, and SIMD: how pgrust makes analytical queries faster.
- Postgres in Rust: three dead ends before we passed 100% of the regression suite: what failed before pgrust reached full regression-suite compatibility.
- pgrust: Rebuilding Postgres in Rust with AI: why we started the project.
Testing
The most common question we get about pgrust is: how can anyone trust it? Just because we passed the test suite doesn't mean our code is correct. Getting to the point where people can trust pgrust is our number one priority today. (Getting the regression suite to pass at all took three failed attempts; we wrote up the dead ends in Postgres in Rust: getting the regression suite to pass.)
To achieve that goal, we're taking several different approaches:
- Of the 3000 user facing Postgres functions, we've been able to formally
verify 1000 of them have identical behavior in pgrust with
Kani. In the process of doing so
we found 12 divergences between pgrust and Postgres. Four of those
were bugs in Postgres itself. See
proofs/. - We're engaging with Antithesis to do simulation testing of pgrust to battle test pgrust.
- We're doing aggressive differential fuzz testing to ensure pgrust's behavior is identical to Postgres's.
Conformance suite
The regression suite we run is PostgreSQL's own src/test/regress, vendored
unmodified at crates/postgres-18.6-reference/src/test/regress and driven by
upstream pg_regress against a pgrust server (scripts/pg-regress-fast.sh;
gate: every one of the 231 parallel_schedule files passes byte-for-byte
against the vendor expected output). Prerequisites, the exact local and CI cluster
commands, what the harness counts (files vs lines vs queries), and what can
and cannot be said about the "46,066" figure are in
docs/conformance/README.md; the gate contract
is docs/conformance/regress-gate.md.
Unsafe Code
pgrust uses unsafe code, but only for the specific things that need it. Postgres represents every internal value as a Datum, an untyped 8 byte value, and Rust has no safe equivalent, so the code that packs and unpacks internal values is unsafe. The same goes for the places where pgrust must match Postgres' memory layouts byte for byte.
If there are particular unsafes that are not necessary and removing them would not have an impact on performance, let us know, as we would love to remove more unsafes.
Quickstart
In your browser: , a full pgrust server compiled to WebAssembly, no install.
On your machine: pgrust does not ship its own initdb or psql yet, so
each flow below installs the PostgreSQL 18 client tools first, then downloads
pgrust, then initializes and starts a database. Paste the blocks top to
bottom.
macOS (Apple Silicon)
## PostgreSQL 18 client tools (initdb, psql). The formula is keg-only, so
## Homebrew does not put it on your PATH; the export is required.
brew install postgresql@18
export PATH="$(brew --prefix postgresql@18)/bin:$PATH"
## Download pgrust and verify the checksum. Download with curl: curl does not
## set the quarantine flag a browser download gets, so Gatekeeper stays out of
## the way (see the note below).
curl -LO https://pgrust.com/downloads/v0.3/pgrust-0.3-macos-arm64
curl -LO https://pgrust.com/downloads/v0.3/pgrust-0.3-macos-arm64.sha256
shasum -a 256 -c pgrust-0.3-macos-arm64.sha256
chmod +x pgrust-0.3-macos-arm64
## Create a data directory using Postgres' initdb.
initdb -D /tmp/pgrust-data --no-locale --encoding UTF8 -U postgres
## pgrust reads the timezone database and other data