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.
Popular in RFCs
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









