Saturday, July 18, 2026

pgrust: PostgreSQL => Rust, with AI: 300x speedup

Postgres was rewritten in Rust… and somehow passed every test - YouTube

Based on the video from Better Stack, here is a quick summary of pgrust:

  • What it is: An experimental rewrite of PostgreSQL in Rust.

  • Compatibility: It successfully passes all 46,066 official PostgreSQL regression queries, works with standard psql clients, and can boot directly from an existing Postgres 18.3 data directory.

  • Architecture Shift: It replaces Postgres' traditional process-per-connection model with a thread-per-connection architecture using Rust threads, aiming to improve concurrency, reduce connection overhead, and provide built-in connection pooling.

  • Performance Claims: The project claims potential performance improvements of 50% to 300x for certain workloads, though developers and commenters remain skeptical, viewing it primarily as an AI-assisted experiment rather than a production-ready replacement.

You can check out the source code in the pgrust GitHub repository or try it out directly on the pgrust website.

malisper/pgrust: Postgres rewritten in Rust, now passing 100% of the Postgres regression tests @GitHub

The goal is to make Postgres easier to change from the inside: keep the behavior Postgres-shaped, keep the real Postgres tests as the oracle, and use Rust plus AI-assisted programming to explore deeper server changes.

pgrust — postgres, rewritten in rust


Rebuilding Postgres for 300x faster analytics: batching, operator fusion, and SIMD - malisper.me

The article details how pgrust achieved a 300x speedup over PostgreSQL on analytical database benchmarks (Clickbench) by optimizing its query engine.

While PostgreSQL was designed in the 1980s when disk I/O was the primary bottleneck, modern hardware makes CPU and memory bandwidth the main performance constraints. To address this, pgrust improves upon Postgres's traditional Volcano execution model—which processes data one row at a time with significant function call overhead—by applying three key techniques:

  • Batching: Processes rows in fixed-size batches (e.g., 1024 items at a time) using stack-allocated buffers. This eliminates per-row call overhead and avoids costly memory allocations, speeding up execution by ~2.7x over the basic Volcano model.

  • Operator Fusion: Combines separate query plan operations (such as a sequential scan and an aggregation sum) into a single loop to eliminate array-copying overhead.

  • SIMD (Single Instruction, Multiple Data): Utilizes hardware-level vector instructions to execute arithmetic operations across multiple values simultaneously, driving performance nearly 10x faster than the initial Volcano setup.

Overall, applying these optimizations reduced the benchmark execution time from 1.3 seconds down to 135 ms (compared to ~20 seconds in standard PostgreSQL).



No comments: