Skip to content
FossShelf
Home / Categories / For Data Engineers

Pgrust

Wire-compatible PostgreSQL rewrite in Rust with a JIT query engine.

Replaces —

5.83K starsAGPL-3.0last commit 26 Oct 2026

Who it's for

Database engineers benchmarking Rust-based PostgreSQL implementations

pgrust provides a complete wire-compatible PostgreSQL implementation in Rust at v0.4-beta with formal verification results and published benchmark data. Engineers evaluating Rust's viability for systems-level database work can run pgrust against their own workloads, use the interactive WebAssembly demo at pgrust.com, or compare against the published ClickBench numbers.

You need a stable, production-ready PostgreSQL environment. pgrust is a pre-production implementation; use standard PostgreSQL for any data you cannot afford to lose.

Teams evaluating columnar storage on their existing PostgreSQL workload

pgrcolumnar is accessible to any team using pgrust: create a table with USING pgrcolumnar and run the same SQL queries. This lets teams measure the analytical performance delta between row and columnar storage on their actual queries, not synthetic benchmarks, without switching to a separate analytics database.

Your analytical queries rely on ON CONFLICT or MERGE on the same tables. Both are unsupported on pgrcolumnar tables in v0.4-beta.

Operators running PostgreSQL on Docker who want to test a self-hosted replacement

pgrust's Docker image is a drop-in replacement for the official postgres image. Teams already on containerized PostgreSQL can switch without changing application code by updating the image tag. For operators currently paying for a managed PostgreSQL service and evaluating a self-hosted path, pgrust preserves SQL compatibility while removing per-instance fees.

The workload is production-critical. The makers do not recommend pgrust for production use at this stage.

AI and data engineering teams with heavy jsonb workloads

pgrust's ANALYZE collects jsonb statistics at the key and value level, giving the planner real cardinality estimates for JSON filter queries. Teams storing event data, embeddings metadata, or semi-structured logs in jsonb columns can get accurate query plans without wrapping everything in generated columns or explicit indexing.

Your jsonb access patterns primarily use GIN indexes for containment queries. Standard PostgreSQL handles those well, and pgrust's statistical advantage is most visible on filter queries the planner historically guessed at.

The problem

Running PostgreSQL for both transactional and analytical workloads on the same cluster creates persistent resource contention. Analytical queries hold large amounts of shared memory during long scans, block the buffer pool, and stall OLTP transactions. Tuning work_mem and shared_buffers helps at the margins but does not address the core constraint: the executor processes rows one at a time, and there is no built-in columnar storage path that shares a memory budget with the row store. Operational stability is the second concern. PostgreSQL does not control its own memory ceiling at runtime, so the OS OOM killer is a real failure mode when memory pressure spikes. Individual long-running queries have no scheduler to prevent them from monopolizing the database, and adding analytics extensions brings its own ABI and compatibility constraints.

How it works

Gravity JIT query engine

Compiles each query plan to AArch64 or x86-64 machine code (and WebAssembly in the browser build) using a copy-and-patch JIT built on a low-level IR. Runs every statement type including DML with ON CONFLICT, triggers, PL/pgSQL, and COPY on both columnar and row-store tables. On ClickBench analytical queries with pgrcolumnar, pgrust runs as much as 3x faster than ClickHouse.

Columnar storage with MVCC

pgrcolumnar is a table access method that stores data in compressed columnar parts with zone maps, delete vectors, and background compaction. Writes are transactional and roll back with the transaction; reads see PostgreSQL MVCC snapshots. Small inserts land in a row-store front that gets folded into columnar parts in the background. Create a columnar table with CREATE TABLE events (...) USING pgrcolumnar.

Unified memory manager

A single memory budget covers the buffer pool, columnar caches, and running queries. When the server approaches the limit, pgrust cancels the statement holding the most memory instead of letting the OS kill the server. This removes the OOM-killer failure mode that brings down standard PostgreSQL deployments under memory pressure.

Query scheduler preventing database-wide stalls

A per-query scheduler prevents any single long-running query from monopolizing the server and taking down the database. This targets one of the documented root causes behind PostgreSQL production outages. Combined with the unified memory manager, it makes the server self-protecting under adversarial query patterns.

Wire and SQL dialect compatible with PostgreSQL 18.6

Implements the PostgreSQL wire protocol and SQL dialect completely enough to replace the official postgres image with a single image swap. The Docker image uses the same environment variables (POSTGRES_PASSWORD, POSTGRES_USER, POSTGRES_DB) and data volume paths. Standard psql and PostgreSQL client libraries connect without modification.

Jsonb statistics for the query planner

ANALYZE collects statistics on the keys and values inside jsonb columns, and the query planner uses them for ->, ->>, ?, ?|, and ?& operators. The planner estimates jsonb filters instead of defaulting to a fixed fraction. Enabled by default via pgrust.jsonb_path_stats.

Features

  • Gravity JIT query engine
  • Columnar storage with MVCC
  • Unified memory manager
  • Query scheduler preventing database-wide stalls
  • Wire and SQL dialect compatible with PostgreSQL 18.6
  • Jsonb statistics for the query planner

How to install

Deploy pgrust using Docker as a drop-in replacement for the official PostgreSQL image.

docker run -d --name pgrust -e POSTGRES_PASSWORD=secret -p 5432:5432 malisper/pgrust:v0.4-beta

Recommended for this setup

Strengths

  • Up to 1,600x faster than PostgreSQL on analytical queries: Measured on a c8g.4xlarge (AWS Graviton4), pgrust with pgrcolumnar runs ClickBench's analytical queries up to 1,600x faster than PostgreSQL per query on cold runs, against PostgreSQL's published results on the same instance type. For mixed OLTP and analytics workloads that currently require a separate ClickHouse or Redshift cluster, this narrows or closes the performance gap without a second database.
  • Drop-in Docker replacement for the postgres image: The malisper/pgrust Docker image uses identical environment variables, init scripts, and data volume paths to the official postgres image. Swapping images in docker-compose or Kubernetes requires no application code changes and no migration tooling. It ships as a multi-arch image (amd64 + arm64).
  • Formal verification and differential fuzz testing: 1,397 of 3,400 user-facing PostgreSQL functions have been formally verified to have identical behavior in pgrust using Kani, with 466 more tested against PostgreSQL. The team is also running aggressive differential fuzz testing and engaging Antithesis for simulation testing. This is a systematic correctness approach rather than a pass/fail test suite.
  • AGPL-3.0 with full self-hosting for internal use: pgrust is AGPL-3.0 licensed and fully self-hostable. You can run it on your own infrastructure, including for commercial internal use, without licensing fees. The AGPL requires distributing source code if you modify pgrust and run it as a network service for external users, but this does not affect teams running it as their own internal database.

Trade-offs

  • Not production-ready: v0.4-beta with known bugs: The makers are explicit: pgrust should not be used in production, and they recommend keeping PostgreSQL as the source of truth for data you cannot afford to lose. The team acknowledges many bugs remain and states testing and reliability are the current top priority. There are 55 open issues as of this writing.
  • Third-party PostgreSQL extensions do not work: There is no stable extension ABI in pgrust. PL/Python, PL/Perl, and PL/Tcl are not supported. pgrust ships a bundled set including pgvector, pg_cron, pg_stat_statements, pg_trgm, hstore, pgcrypto, and postgres_fdw, but extensions that compile against the C PostgreSQL API cannot be loaded.
  • AGPL-3.0 requires source disclosure for network services: If you modify pgrust and run it as a managed service for external users, AGPL-3.0 requires you to provide the source code of those modifications. Teams building SaaS products on top of a modified pgrust must plan for source disclosure. Internal and personal use is not affected by this clause.
  • ON CONFLICT and MERGE unsupported on columnar tables: ON CONFLICT and MERGE are not supported on pgrcolumnar tables in v0.4-beta. If your workload uses upsert patterns heavily on tables you want in columnar format, you will need to work around this or keep those tables in the row store. Row-store tables support both operations normally.

Tech stack

Languages
Rust, C, PLpgSQL, Python, C++, Perl, Yacc, Meson, Makefile, Shell, JavaScript, Ruby, Lex, M4, HTML, XSLT, PLSQL, CMake, Roff, Awk, CSS, XS, Emacs Lisp, Starlark, DTrace, Assembly, RenderScript, WebAssembly, sed, GLSL
Frameworks
—
Databases
PostgreSQL
Tooling
—

FAQ

Is pgrust production-ready?

No. The makers explicitly state that pgrust should not be run in production and recommend keeping PostgreSQL as the source of truth for data you cannot afford to lose. It is at v0.4-beta and reliability is the current top development priority.

Is pgrust wire-compatible with PostgreSQL? Can I use my existing drivers and tools?

Yes. pgrust implements the PostgreSQL wire protocol and SQL dialect of PostgreSQL 18.6. Standard PostgreSQL clients, drivers, and psql connect without modification. The Docker image uses the same environment variables and data volume paths as the official postgres image, making it a drop-in replacement in containerized setups.

Does pgrust support PostgreSQL extensions?

pgrust does not support third-party extensions because there is no stable extension ABI yet. PL/Python, PL/Perl, and PL/Tcl are not supported. pgrust ships a bundled set including pgvector, pg_cron, pg_stat_statements, pg_trgm, hstore, pgcrypto, and postgres_fdw. Extensions that compile against the C PostgreSQL API cannot be loaded.

Can I use pgrust commercially?

AGPL-3.0 permits running pgrust on your own infrastructure, including for internal commercial use, without restriction. The license requires making source code available if you modify pgrust and run it as a public network service for external users. Teams using pgrust as their own internal database are not affected by this clause.

How does pgrust compare to ClickHouse for analytical queries?

In ClickBench benchmarks, pgrust with pgrcolumnar runs analytical queries as much as 3x faster than ClickHouse. The key difference is that pgrust is also PostgreSQL-compatible, so you can run analytics on the same server without switching SQL dialects or maintaining a separate database. ClickHouse is a mature production system; pgrust is pre-production and not yet suitable for workloads where ClickHouse already serves you.

Similar tools

More in Data Engineers