What Is pgGraph?
pgGraph is a PostgreSQL extension built by Evokoa that adds graph search, traversal, shortest-path, and relationship queries to ordinary tables for developers, DBAs, and platform teams. pgGraph is one of the best PostgreSQL Graph Extensions tools for developers, DBAs, and platform teams that want graph queries inside Postgres. It ships as v0.1.1, supports PostgreSQL 13-18, and keeps the database you already run as the source of truth.
The point is simple: you do not need a second database just to answer hop-distance and connectedness questions. pgGraph lets you ask graph-shaped questions against relational data from the graph schema while leaving constraints, ACLs, backups, and application writes in PostgreSQL.
Quick Overview
| Attribute | Details |
|---|---|
| Type | PostgreSQL Graph Extensions |
| Best For | developers, DBAs, and platform teams that want graph queries inside Postgres |
| Language/Stack | Rust, pgrx, PostgreSQL 13-18, Docker |
| License | Apache 2.0 |
| GitHub Stars | N/A |
| Pricing | Open-Source |
| Last Release | v0.1.1 — date not shown on page |
Who Should Use pgGraph?
- Postgres-first teams that already model core data in relational tables and want graph traversal without standing up Neo4j or another dedicated graph store.
- Backend engineers who need hop-based lookups, relationship discovery, or shortest-path queries directly in SQL instead of hand-rolled recursive CTEs.
- Platform and data engineers who need derived graph state while keeping the base tables, indexes, and permissions fully standard PostgreSQL.
- Prototype-heavy teams that want to test graph workloads quickly in Docker before deciding whether a dedicated graph database is justified.
Not ideal for:
- Production systems with strict stability requirements because pgGraph is explicitly marked early alpha and the project asks users to avoid production use for now.
- Teams that need write-heavy graph transactions because pgGraph is designed as derived state over Postgres tables, not as a primary graph-native OLTP store.
- Organizations that cannot match PostgreSQL major versions between extension build artifacts and target servers, since package compatibility matters here.
Key Features of pgGraph
- Graph traversal on top of tables — pgGraph runs graph-style queries directly against existing PostgreSQL tables, so your relational schema remains the system of record. That means no ETL into a separate graph engine and no duplicate storage model to keep in sync.
- Derived graph index in the
graphschema — the extension builds a graph layer from relational metadata and exposes SQL-facing functions in a dedicated schema. This keeps graph operations discoverable to database users who already live in SQL. - CSR-backed adjacency storage —
graph.build()compiles relationships into forward and reverse compressed sparse row (CSR) edge stores. CSR keeps neighbor lookup contiguous in memory, which is exactly what you want for traversal-heavy workloads. - Memory-mapped graph artifacts — pgGraph persists
.pggraphfiles and mmaps them on backend startup. That design lets PostgreSQL processes reuse the OS page cache instead of copying a graph heap into each backend. - Traversal safety controls — the engine uses depth limits, visited-node tracking, frontier limits, pagination, and memory guards. Those controls matter because unbounded traversal can turn a normal database query into a resource problem.
- PostgreSQL-native operational model — source tables, constraints, backups, RLS, and app writes stay standard PostgreSQL concerns. pgGraph only manages derived state, which keeps the operational blast radius smaller than a separate graph cluster.
- Built for controlled environments first — the repo includes Docker-backed quickstart flows and a Streamlit playground for sample datasets like
panamaandldbc. That makes it practical for evaluation, demos, and internal proof-of-concepts.
pgGraph vs Alternatives
| Tool | Best For | Key Differentiator | Pricing |
|---|---|---|---|
| pgGraph | Postgres-native graph traversal and shortest-path queries | Keeps data in PostgreSQL and builds a derived graph index with CSR-backed reads | Open-Source |
| Neo4j | Full graph database workloads and graph-first data modeling | Mature native graph engine with its own storage and query language | Paid / Freemium |
| Apache AGE | PostgreSQL users who want Cypher-style graph querying | Adds graph capabilities inside PostgreSQL with a different abstraction layer | Open-Source |
| Recursive SQL | Small, one-off graph questions in pure SQL | No extension install, but every query becomes custom recursive logic | Free |
Pick Neo4j if graph is your primary data model and you want a mature graph-native platform with a deep ecosystem. Pick Apache AGE if you want graph semantics inside PostgreSQL but prefer Cypher-style querying over pgGraph’s derived-index approach.
Pick recursive SQL when the graph question is tiny, the schema is stable, and you do not want to install anything. Pick pgGraph when the query pattern is repeated, the traversal depth matters, and you want graph behavior without moving data out of Postgres.
If your bottleneck is understanding query behavior rather than graph traversal itself, OpenTrace pairs well with pgGraph because it helps inspect execution paths and latency once graph queries hit PostgreSQL. For teams comparing the broader database-tooling landscape, browse all database tools for adjacent options.
How pgGraph Works
pgGraph works by treating PostgreSQL as the authoritative storage layer and building a graph runtime from relational metadata. The core abstraction is a derived graph index, not a new source of truth, so the engine can resolve nodes, labels, and filters from tables and then traverse a compact in-memory representation.
The technical choice that matters most is CSR adjacency storage. During graph.build(), pgGraph converts relationships into forward and reverse compressed sparse row arrays, then persists them as atomic artifacts that can be mmapped by PostgreSQL backends. That keeps traversal close to memory-speed access patterns and avoids repeatedly re-discovering edges through joins or recursive CTEs.
The engine also adds guardrails around traversal behavior. It tracks visited nodes, limits depth and frontier size, and applies memory safeguards so a bad query does not explode into runaway expansion.
git clone https://github.com/evokoa/pggraph.git
cd pggraph
scripts/quickstart.sh
That quickstart launches a disposable Docker-backed PostgreSQL instance, installs pgGraph, creates sample tables, discovers the foreign-key relationship, builds the graph, and runs example queries. If you already have a Dockerized Postgres container, you can target it directly with scripts/quickstart.sh docker my-postgres 17 appdb postgres.
Pros and Cons of pgGraph
Pros:
- Keeps PostgreSQL as the source of truth so you do not duplicate application data into a second graph store.
- Uses CSR and mmap for traversal-oriented access patterns, which is a sensible design for read-heavy graph lookups.
- Supports PostgreSQL 13-18 for packaged extension builds, which makes it usable across a wide Postgres fleet.
- Exposes graph operations through SQL so existing Postgres users do not need a separate query language to get started.
- Includes safety limits like visited-node tracking and depth controls, which are necessary for production-like traversal workloads even during evaluation.
- Provides a quick Docker path for local experiments, demos, and repeatable testing.
Cons:
- Early alpha status means you should not treat pgGraph as production-ready yet.
- Major-version alignment matters because the extension package must match the target PostgreSQL server version.
- Derived-state architecture adds rebuild steps when underlying relationships change, so it is not a zero-maintenance overlay.
- Graph semantics are narrower than a full graph database because the project focuses on traversal and relationship queries over Postgres tables.
- Windows support is terminal-specific since the quickstart expects WSL2 or Git Bash rather than native PowerShell or Command Prompt.
Getting Started with pgGraph
The fastest path is the repository quickstart, which is designed to work from Docker-backed environments with minimal setup. Use the included script to clone the repo, launch the demo database, and execute the sample graph workflow.
git clone https://github.com/evokoa/pggraph.git
cd pggraph
scripts/quickstart.sh playground panama
If you want to install into an existing container or build locally with pgrx, the same script supports docker and pgrx modes. After the first run, expect the extension to discover relationships, compile the graph artifacts, and surface example traversal queries in PostgreSQL.
Verdict
pgGraph is the strongest option for Postgres-native graph traversal when you need relationship queries without introducing a separate graph database. Its biggest strength is the CSR-backed derived graph layer inside PostgreSQL, while its biggest caveat is the early-alpha status and version-matched packaging. Use it for evaluation, internal tooling, and controlled deployments, not mission-critical production today.



