Fast graph analytics
inside PostgreSQL.
A graph engine inside Postgres. Find paths, rank what matters, spot communities, and test changes before you commit them. All in SQL, on the tables you already have.
In our benchmarks over 12 real graphs, pg_warren was faster than pgGraph 1.2.1 on every workload both support (2.4–89× on shortest paths, 1.7–14× on connected components) and outperformed Neo4j + GDS on shortest-path and Louvain workloads, running entirely inside PostgreSQL. See results and methodology for the warm medians, shared 4-vCPU setup, and workloads where other engines are faster.
SQL-callable functions
Transactional graph versions
No separate graph service
Traverse a graph.
Join the results.
This breadth-first search returns nodes within three hops of Ada, including the start at depth zero. The result joins directly to the people table by external id.
Explore traversalSELECT p.name, b.depth
FROM warren.bfs('social', ARRAY[1::bigint], 3) b
JOIN people p ON p.id = b.node_id
ORDER BY b.depth, p.name;| NAME | DEPTH |
|---|---|
| ada | 0 |
| bob | 1 |
| cy | 2 |
| dee | 3 |
This query reads a built graph version. Refresh the graph to include later table changes.
See the complete example setup
CREATE EXTENSION pg_warren;
CREATE TABLE people (id bigint PRIMARY KEY, name text NOT NULL);
CREATE TABLE follows (src bigint NOT NULL, dst bigint NOT NULL);
INSERT INTO people VALUES
(1, 'ada'), (2, 'bob'), (3, 'cy'), (4, 'dee'), (5, 'eve');
INSERT INTO follows VALUES (1, 2), (2, 3), (3, 1), (3, 4), (4, 5);
SELECT warren.create_graph('social',
'SELECT id FROM people', 'SELECT src, dst FROM follows');
SELECT warren.refresh('social');After installing the extension, run this setup in a fresh database, then run the query above. The example and its results are checked in the project’s SQL documentation tests.
Traversal, compute,
and change detection.
One compact adjacency structure supports path queries, iterative graph algorithms, and structural comparisons between graph versions.
Deep traversal
Breadth-first search, reachability, shortest paths, and typed walks with relation and node filters.
Traversal 02Graph algorithms
PageRank, connected components, Louvain, Leiden, and spectral analysis over the same graph versions.
Algorithms & communities 03Version comparisons
Build a staged version, compare its structure, and decide whether to commit. In one transaction.
Versions & change detectionFrom tables to graph
to SQL results.
Define your nodes and edges with two SQL queries. pg_warren builds a compact, memory-resident CSR adjacency structure. Your tables remain the source of truth.
- 01
Your tables
Nodes and edges.
Defined with SQL.create_graph - 02
A graph version
Immutable. Transactional.
Built when you choose.refresh - 03
Follow or compute
Paths, vectors,
and whole-graph algorithms.warren.* - 04
Back to your rows
Join by node id.
Keep using SQL.JOIN
Small frontiers are a natural fit for recursive SQL. When a traversal touches a large part of the graph—or an algorithm repeatedly works over all of it—pg_warren gives that work a dedicated engine.
Find the right fitUse pg_warren
Install the extension, define a graph, and run your first query.