WyvernoDragon

WyvernoDragon

pgRx - PostgreSQL-compatible query engine built on BEAM + Rust

I’ve been working on pgRx: a query engine that uses BEAM lightweight processes instead of PostgreSQL’s fork-per-connection model.

The numbers: 50 idle connections cost PostgreSQL 729MB additional memory. On pgRx it’s 0KB. Hibernated BEAM processes drop to ~400 bytes each.

How it works:

  • Each connection is a GenServer (~2KB active, hibernated to
    ~400 bytes when idle)
  • SQL parsing and execution happens in a Rust NIF via
    pg_query (the same parser PostgreSQL uses)
  • Shared state via RwLock — no per-connection data
    duplication
  • Wire protocol v3 implemented — psql connects without
    changes

What works today: JOINs (all types), subqueries, aggregates, GROUP BY, HAVING, ORDER BY, INSERT/UPDATE/DELETE with RETURNING, prepared statements.

The thesis: PostgreSQL’s process-per-connection model is essentially a worse version of BEAM’s actor model. OpenAI runs 800M ChatGPT users on a single PostgreSQL and has already hit connection storms causing outages. The architecture hasn’t changed since 1986. BEAM was built for exactly this problem at Ericsson - millions of concurrent isolated processes.

GitHub:

https://github.com/JagritGumber/pgrx

Demo site:

Would love to know the parts that have been annoying you, so I can fix them with this iteration.

Where Next?

Trending in RFCs Top

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement