PRE-1.0 · IN DEVELOPMENT

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.

A warren of connections beneath your tablesA conceptual diagram: nodes and edges from ordinary PostgreSQL tables connect through a branching graph, with a highlighted traversal path.START010203your ordinary tables
POSTGRESQL 15–18

SQL-callable functions

Transactional graph versions

No separate graph service

SQL EXAMPLE

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 traversal
social.sql
SELECT 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;
NAMEDEPTH
ada0
bob1
cy2
dee3
Ada’s neighbourhood, up to three hops.

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.

ARCHITECTURE

From 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.

  1. 01

    Your tables

    Nodes and edges.
    Defined with SQL.

    create_graph
  2. 02

    A graph version

    Immutable. Transactional.
    Built when you choose.

    refresh
  3. 03

    Follow or compute

    Paths, vectors,
    and whole-graph algorithms.

    warren.*
  4. 04

    Back to your rows

    Join by node id.
    Keep using SQL.

    JOIN
WHEN TO USE IT

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 fit
INSTALLATION & DOCUMENTATION

Use pg_warren

Install the extension, define a graph, and run your first query.