Skip to content
industry insights

Postgres Just Got Rewritten in Rust

A new project called pgrust has completely rewritten Postgres in Rust, and it passes every single regression test. But the real story isn't just speed—it's how AI made this 'impossible' feat a reality.

Cassidy Wolfe
Hero image for: Postgres Just Got Rewritten in Rust

TL;DR / Key Takeaways

  • A new project called pgrust has completely rewritten Postgres in Rust, and it passes every single regression test.
  • But the real story isn't just speed—it's how AI made this 'impossible' feat a reality.

Beyond a Fork: A Perfect Clone?

A full rewrite of Postgres in Rust, christened pgrust, has dropped, and it’s far more than a mere academic exercise. This audacious project has achieved the monumental feat of passing all 46,000+ official Postgres regression queries – a benchmark that few, if any, "compatible" databases truly dare to claim. This isn't just a nod to compatibility; it's a declaration.

Crucially, pgrust is not a fork of the existing C codebase, nor is it an extension bolted onto the original. It represents a complete, ground-up reimplementation, meticulously engineered for 100% behavioral compatibility with Postgres 18.3. The goal was not to tweak the old engine, but to entirely replace it with Rust, preserving every nuance of the external contract.

The outcome is a database server that is, from the outside, utterly indistinguishable from its C-based predecessor. It speaks the exact wire protocol, allowing seamless integration with standard `psql` clients. More astonishingly, pgrust can even boot directly from an existing Postgres 18.3 data directory, demonstrating a level of disk compatibility that blurs the line between a new engine and an outright clone. This isn't just surface-level mimicry; it's a deep, foundational congruence.

The Real Goal: Threads Over Processes

Postgres, for all its stability, relies on a heavy process-per-connection model. Each client demands its own backend process, offering robust isolation but incurring significant memory overhead. This design also complicates state sharing for parallel operations, often necessitating connection pooling.

pgrust, however, charts a different course in its unreleased, experimental version. It aims to replace this with a thread-per-connection architecture. This shift promises lower memory consumption per connection and simplifies sharing information across different database components, a critical advantage for modern workloads.

Yet, this architectural pivot introduces a crucial tradeoff. Postgres's process isolation provides a crucial safety net: a crash in one connection typically won't fell the entire server. With threads, a single memory bug or unsafe extension could potentially destabilize the whole process, removing some of those inherent safety rails.

This fundamental re-architecture underpins pgrust's most audacious performance claims. Developers report an unverified 50% boost for transactional workloads and a staggering 300x improvement for analytical queries in this unreleased version. These dramatic figures remain speculative, as the code backing these benchmarks is not yet publicly available for independent verification.

The Secret Weapon: AI-Driven Development

Monumental rewrite of Postgres into pgrust was not merely a testament to Rust's capabilities; it was an audacious demonstration of AI-driven development. Michael Malis and Jason Seibel leveraged AI coding agents extensively, allowing them to translate Postgres’s million-line C codebase with astonishing speed and feasibility. This monumental task, previously unthinkable for a small team, became tractable through automated translation, fundamentally altering the economics of such an undertaking.

This reveals the true experiment at play: not just whether Rust can make Postgres faster, but if AI can make rewriting legacy infrastructure affordable enough to rethink core architecture. Decades of accumulated C code, once considered an untouchable monolith, became a feasible target for deep architectural change. The published pgrust version largely mirrors Postgres's original structure, but the unreleased thread-per-connection model shows the real ambition for fundamental design shifts.

This paradigm shift fundamentally redefines the cost-benefit analysis for modernizing other large-scale, decades-old software projects. Systems like Linux, Apache, or even older enterprise applications, previously deemed too expensive or risky to rewrite, now enter the realm of possibility. AI agents dramatically reduce the initial translation burden, freeing human engineers to focus on innovative architectural overhauls, as detailed further at malisper/pgrust: Postgres rewritten in Rust, now passing 100% of the Postgres regression tests - GitHub.

Hype vs. Reality: The Verdict on pgrust

Unsurprisingly, the engineering community’s verdict on pgrust is sharply divided. While many developers express immense respect for an achievement like passing all 46,000+ official Postgres regression queries, healthy skepticism remains. Unverified benchmarks, claiming 50% better transactional performance and 300 times faster analytical workloads from an unreleased version, fuel this caution.

Enjoying this? Get one like it in your inbox each morning.

one email a day · unsubscribe in two clicks · no third-party tracking

Make no mistake: pgrust is a groundbreaking experiment, not a production-ready replacement. Core areas like the extensive extension ecosystem remain unfinished, and the critical hardening required for crash recovery and long-term stability is yet to be realized. Deploying this in a live environment would be irresponsible.

Ultimately, pgrust’s most profound contribution may not be a single benchmark or even a direct replacement for Postgres. Instead, its true value lies in the unprecedented freedom it creates. Enabled by AI-driven development, this project demonstrates the feasibility of testing radical new database architectures, such as a thread-per-connection model, without the prohibitive cost and complexity of forking the entire Postgres project.

Frequently Asked Questions

What is pgrust?

pgrust is a complete, from-scratch rewrite of the Postgres database in the Rust programming language. It aims to be a drop-in replacement that is behaviorally identical, having passed all 46,000+ of Postgres's official regression tests.

Is pgrust faster than Postgres?

The current released version of pgrust is not focused on performance. However, an unreleased development version claims significant speedups—up to 50% on transactional workloads and 300x on analytical workloads—by switching to a thread-per-connection model.

Can I use pgrust in production?

No. The developers state that pgrust is not production-ready. While it passes regression tests, it has not undergone the years of real-world testing required for production trust, especially in areas like crash recovery and replication.

How was AI used to build pgrust?

The developers used AI-powered coding agents extensively to accelerate the massive task of translating nearly a million lines of C code into Rust. This made an otherwise prohibitively expensive experiment feasible.

Found this useful? Share it.

For business owners

What could AI actually do for your business?

Paste your website — in 60 seconds you get the exact off-the-shelf tools that give you your week back, with real costs and honest ROI. Free, no signup, no sales call.

Assess my business →

One short daily email of tools worth shipping. No drip funnel.

one email a day · unsubscribe in two clicks · no third-party tracking

🚀Discover More

Stay Ahead of the AI Curve

Discover the best AI tools, agents, and MCP servers curated by Stork.AI. Find the right solutions to supercharge your workflow.

P.S. Built something worth using? List it on Stork