Back to Devoured - August 06, 2026
DEVOURED
pgGraph (GitHub Repo)

pgGraph (GitHub Repo)

Data GitHub
pgGraph enables high-performance graph traversals directly within PostgreSQL by compiling relational data into memory-efficient, cache-friendly CSR structures.
What: pgGraph is a Rust-based PostgreSQL extension that adds graph search, traversal, and shortest-path functionality using derived Compressed Sparse Row (CSR) indexes without requiring data migration.
Why it matters: It offers an alternative to moving data into dedicated graph databases like Neo4j or complex recursive SQL, keeping the relational database as the single source of truth.
Takeaway: Test your graph performance using the provided Docker-based quickstart script or add the `graph` extension to your PostgreSQL 17 instance via `CREATE EXTENSION graph;`.
Deep dive
  • Uses CSR (Compressed Sparse Row) storage to ensure O(1) neighbor adjacency lookups.
  • Implemented as an immutable, rebuildable index rather than a storage engine.
  • Protects against infinite loops and memory spikes with explicit depth, frontier, and visited-node circuit breakers.
  • Bypasses slow recursive SQL/JOIN patterns by streaming native memory scans within the database backend.
  • Supports atomic artifact mapping, allowing the OS page cache to share index data across multiple Postgres connections.
Decoder
  • CSR (Compressed Sparse Row): A memory-efficient data structure for storing sparse graphs where edge lists are stored as contiguous arrays, enabling high-speed neighbor traversal.
  • System of Record: The authoritative database where the primary, canonical copy of data resides.
Original article

pgGraph

Graph database superpowers for your existing Postgres data.

pgGraph is a PostgreSQL extension for running graph search, traversal, shortest path, and relationship queries directly against ordinary PostgreSQL tables.

Your tables stay the source of truth. pgGraph builds a derived graph index and lets you query it from SQL using functions in the graph schema.

Looking for a managed version? We have launched a managed version of pgGraph on polygres.com for full high performance GraphRAG on Postgres.

Why pgGraph?

PostgreSQL is great at relational queries, but graph-style questions often require custom recursive SQL for each schema:

  • “Find records related to Alice within 2 hops.”
  • “Find the shortest path between this person and this company.”
  • “Search nodes across registered tables.”

pgGraph adds graph queries on top of your existing PostgreSQL tables, without requiring a separate graph database, graph-specific storage system, or a new query language.

Quickstart

The repository quickstart builds a disposable PostgreSQL 17 image:

git clone https://github.com/evokoa/pggraph.git
cd pggraph
scripts/quickstart.sh

The signed multi-architecture release image is ghcr.io/evokoa/pggraph:1.0.0. Verify its published digest before deployment.

Verify the extensions are loaded (uses psql inside the container, so you don't need a local PostgreSQL client):

docker exec pggraph psql -U postgres -d graph \
  -c "SELECT extname, extversion FROM pg_extension WHERE extname IN ('graph', 'pg_cron');"

If you have psql installed locally you can also connect directly:

psql -h localhost -U postgres -d graph

Homebrew Installation

The Evokoa Homebrew tap is the convenience channel for local PostgreSQL 17 extension installs.

brew tap Evokoa/tap
brew install pggraph
brew test pggraph

Create and verify the extension in a local database:

brew services start postgresql@17
psql -d postgres -c "CREATE EXTENSION graph;"
psql -d postgres -c "SELECT extname, extversion FROM pg_extension WHERE extname = 'graph';"

The formula installs pgGraph 1.0.0 from the signed release bundle.

PGXN Source Installation

PGXN provides the verified source ZIP from the signed 1.0.0 release bundle. Because pgGraph is a Rust/pgrx extension, building from source requires the Rust toolchain.

Prerequisites

  • PostgreSQL development headers and pg_config
  • Rust toolchain (1.96, pinned by graph/rust-toolchain.toml)
  • cargo-pgrx 0.19.1

Install with pgxn-client

cargo install cargo-pgrx --version 0.19.1 --locked
# Register the installed PostgreSQL with pgrx (auto-detects the major):
PG_MAJOR=$(pg_config --version | sed -E 's/[^0-9]*([0-9]+).*/\1/')
cargo pgrx init --pg${PG_MAJOR}="$(which pg_config)"
pgxn install pgGraph

Manual source install

git clone https://github.com/evokoa/pggraph.git
cd pggraph
make install # may need sudo
psql -d postgres -c "CREATE EXTENSION graph;"

Documentation

More information is available in the pgGraph docs:

Overview · Quickstart · Installation · Playground · Querying · SQL API

pgGraph: High-Speed Graph Execution Inside PostgreSQL

pgGraph is not "Postgres plus graph syntax." It is a cache-friendly graph execution layer for data that already lives in your ordinary relational tables.

The core idea is simple but powerful: keep PostgreSQL as your system of record, but build a highly optimized, read-heavy graph runtime from that relational metadata.

The Tech: Why It's So Fast

  • O(1) adjacency via CSR. graph.build() compiles your relationships into forward and reverse compressed sparse row (CSR) edge stores.
  • A tight traversal loop. Once inside, the engine streams CSR neighbors, checking compact u8 edge-label IDs, typed FilterIndex values, tenant bitmaps, active bits, and sync overlays.
  • Read-only artifact mapping. Persisted .pggraph artifacts are written atomically, allowing the operating system page cache to share those physical pages across isolated PostgreSQL backends.
  • Predictable and safe. pgGraph includes explicit circuit breakers: depth limits, visited-node tracking, frontier limits, pagination, and strict OOM/memory safeguards.

PostgreSQL Remains Authoritative

Your application data does not move. Source tables, constraints, indexes, ACLs, RLS, backups, and app writes remain 100% standard PostgreSQL concerns.

How pgGraph Compares

vs. Apache AGE: Execution Layer vs. Storage Layer

Apache AGE is a property graph database inside Postgres. pgGraph does not ask you to move your data or learn Cypher. Use AGE for a dedicated property graph model; use pgGraph to add bounded, high-speed graph traversal to an existing relational schema.

vs. PostgreSQL 19 SQL/PGQ

SQL:2023 and PostgreSQL 19 introduce CREATE PROPERTY GRAPH. pgGraph operates at a different layer by precomputing CSR adjacency stores for workloads that repeatedly traverse the same topology with bounded depth and path limits.

Community

pgGraph is built by Evokoa.

License

Apache-2.0.

Explore all 58 articles in today's digest

Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi