pgrx is a Rust framework for building PostgreSQL extensions across Postgres 13-18, with a full cargo-pgrx toolchain and automatic type mapping.
Key Takeaways
cargo-pgrx CLI covers the full lifecycle: new, init, run, test, package, and schema generation without a local Postgres install required on Linux/macOS.
Safety model converts Rust panic! into Postgres ERRORs that abort transactions rather than the process; #[pg_guard] macro and Rust drop semantics handle memory even through elog(ERROR).
Comprehensive Rust-to-Postgres type mapping includes jsonb, ranges, UUIDs, and custom types via #[derive(PostgresType)] and #[derive(PostgresEnum)]; NULL maps cleanly to Option<T>::None.
First-class UDF support via #[pg_extern]; return SetOfIterator or TableIterator for RETURNS SETOF and RETURNS TABLE respectively.
Known hard limits: Postgres is single-threaded so spawned threads must never call Postgres internals, and async context interaction is explicitly uncharted.
Hacker News Comment Review
Production signal is strong: multiple commenters report real production deployments with zero memory unsafety or race conditions, and at least one company built an entire ML-in-Postgres product on pgrx.
The biggest practical constraint raised is managed Postgres compatibility – AWS RDS blocks arbitrary custom extensions entirely; Supabase is mentioned as a curated middle ground with pgvector, PostGIS, and pg_cron pre-approved.
At least one commenter assumed the project was abandoned, suggesting discoverability or release cadence is a gap despite active Discord maintainer presence.
Notable Comments
@dukepiki: PlanetScale runs Insights, Traffic Control, and pg_strict on pgrx in production – “zero memory unsafety and race conditions in a year.”
@K0nserv: Built plid with pgrx but had to drop #[derive(PostgresType)] in practice; confirms RDS blocks custom extensions entirely.