跳转到主要内容

pg_warren

Versioned graph traversal and computation over PostgreSQL tables

pg_warren : Versioned graph traversal and computation over PostgreSQL tables

Overview

ID Extension Package Version Category License Language
2645 pg_warren pg_warren 0.8.0 FEAT Apache-2.0 Rust
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-dt- No Yes No Yes no yes
Relationships
Schemas warren
Shared cache preload on PG15–16

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 0.8.0 19 18 17 16 15 pg_warren -
RPM PIGSTY 0.8.0 19 18 17 16 15 pg_warren_$v -
DEB PIGSTY 0.8.0 19 18 17 16 15 postgresql-$v-pg-warren -
Linux / PG PG19 PG18 PG17 PG16 PG15
el8.x86_64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
el8.aarch64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
el9.x86_64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
el9.aarch64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
el10.x86_64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
el10.aarch64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
d12.x86_64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
d12.aarch64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
d13.x86_64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
d13.aarch64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
u22.x86_64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
u22.aarch64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
u24.x86_64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
u24.aarch64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
u26.x86_64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
u26.aarch64 N/A PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0 PIGSTY 0.8.0
Package Version OS ORG SIZE File URL
pg_warren_18 0.8.0 el8.x86_64 pigsty 3.0 MiB pg_warren_18-0.8.0-1PGSTY.el8.x86_64.rpm
pg_warren_18 0.8.0 el8.aarch64 pigsty 2.4 MiB pg_warren_18-0.8.0-1PGSTY.el8.aarch64.rpm
pg_warren_18 0.8.0 el9.x86_64 pigsty 2.9 MiB pg_warren_18-0.8.0-1PGSTY.el9.x86_64.rpm
pg_warren_18 0.8.0 el9.aarch64 pigsty 2.6 MiB pg_warren_18-0.8.0-1PGSTY.el9.aarch64.rpm
pg_warren_18 0.8.0 el10.x86_64 pigsty 2.9 MiB pg_warren_18-0.8.0-1PGSTY.el10.x86_64.rpm
pg_warren_18 0.8.0 el10.aarch64 pigsty 2.6 MiB pg_warren_18-0.8.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-warren 0.8.0 d12.x86_64 pigsty 2.6 MiB postgresql-18-pg-warren_0.8.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-warren 0.8.0 d12.aarch64 pigsty 2.1 MiB postgresql-18-pg-warren_0.8.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-warren 0.8.0 d13.x86_64 pigsty 2.6 MiB postgresql-18-pg-warren_0.8.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-warren 0.8.0 d13.aarch64 pigsty 2.1 MiB postgresql-18-pg-warren_0.8.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-warren 0.8.0 u22.x86_64 pigsty 2.8 MiB postgresql-18-pg-warren_0.8.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-warren 0.8.0 u22.aarch64 pigsty 2.5 MiB postgresql-18-pg-warren_0.8.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-warren 0.8.0 u24.x86_64 pigsty 2.8 MiB postgresql-18-pg-warren_0.8.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-warren 0.8.0 u24.aarch64 pigsty 2.4 MiB postgresql-18-pg-warren_0.8.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-warren 0.8.0 u26.x86_64 pigsty 2.8 MiB postgresql-18-pg-warren_0.8.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-warren 0.8.0 u26.aarch64 pigsty 2.4 MiB postgresql-18-pg-warren_0.8.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_warren_17 0.8.0 el8.x86_64 pigsty 3.0 MiB pg_warren_17-0.8.0-1PGSTY.el8.x86_64.rpm
pg_warren_17 0.8.0 el8.aarch64 pigsty 2.4 MiB pg_warren_17-0.8.0-1PGSTY.el8.aarch64.rpm
pg_warren_17 0.8.0 el9.x86_64 pigsty 2.9 MiB pg_warren_17-0.8.0-1PGSTY.el9.x86_64.rpm
pg_warren_17 0.8.0 el9.aarch64 pigsty 2.6 MiB pg_warren_17-0.8.0-1PGSTY.el9.aarch64.rpm
pg_warren_17 0.8.0 el10.x86_64 pigsty 2.9 MiB pg_warren_17-0.8.0-1PGSTY.el10.x86_64.rpm
pg_warren_17 0.8.0 el10.aarch64 pigsty 2.6 MiB pg_warren_17-0.8.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-warren 0.8.0 d12.x86_64 pigsty 2.6 MiB postgresql-17-pg-warren_0.8.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-warren 0.8.0 d12.aarch64 pigsty 2.1 MiB postgresql-17-pg-warren_0.8.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-warren 0.8.0 d13.x86_64 pigsty 2.6 MiB postgresql-17-pg-warren_0.8.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-warren 0.8.0 d13.aarch64 pigsty 2.1 MiB postgresql-17-pg-warren_0.8.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-warren 0.8.0 u22.x86_64 pigsty 2.8 MiB postgresql-17-pg-warren_0.8.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-warren 0.8.0 u22.aarch64 pigsty 2.5 MiB postgresql-17-pg-warren_0.8.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-warren 0.8.0 u24.x86_64 pigsty 2.8 MiB postgresql-17-pg-warren_0.8.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-warren 0.8.0 u24.aarch64 pigsty 2.4 MiB postgresql-17-pg-warren_0.8.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-warren 0.8.0 u26.x86_64 pigsty 2.8 MiB postgresql-17-pg-warren_0.8.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-warren 0.8.0 u26.aarch64 pigsty 2.4 MiB postgresql-17-pg-warren_0.8.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_warren_16 0.8.0 el8.x86_64 pigsty 3.0 MiB pg_warren_16-0.8.0-1PGSTY.el8.x86_64.rpm
pg_warren_16 0.8.0 el8.aarch64 pigsty 2.4 MiB pg_warren_16-0.8.0-1PGSTY.el8.aarch64.rpm
pg_warren_16 0.8.0 el9.x86_64 pigsty 2.9 MiB pg_warren_16-0.8.0-1PGSTY.el9.x86_64.rpm
pg_warren_16 0.8.0 el9.aarch64 pigsty 2.6 MiB pg_warren_16-0.8.0-1PGSTY.el9.aarch64.rpm
pg_warren_16 0.8.0 el10.x86_64 pigsty 2.9 MiB pg_warren_16-0.8.0-1PGSTY.el10.x86_64.rpm
pg_warren_16 0.8.0 el10.aarch64 pigsty 2.6 MiB pg_warren_16-0.8.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-warren 0.8.0 d12.x86_64 pigsty 2.6 MiB postgresql-16-pg-warren_0.8.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-warren 0.8.0 d12.aarch64 pigsty 2.1 MiB postgresql-16-pg-warren_0.8.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-warren 0.8.0 d13.x86_64 pigsty 2.6 MiB postgresql-16-pg-warren_0.8.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-warren 0.8.0 d13.aarch64 pigsty 2.1 MiB postgresql-16-pg-warren_0.8.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-warren 0.8.0 u22.x86_64 pigsty 2.8 MiB postgresql-16-pg-warren_0.8.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-warren 0.8.0 u22.aarch64 pigsty 2.5 MiB postgresql-16-pg-warren_0.8.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-warren 0.8.0 u24.x86_64 pigsty 2.8 MiB postgresql-16-pg-warren_0.8.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-warren 0.8.0 u24.aarch64 pigsty 2.4 MiB postgresql-16-pg-warren_0.8.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-warren 0.8.0 u26.x86_64 pigsty 2.8 MiB postgresql-16-pg-warren_0.8.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-warren 0.8.0 u26.aarch64 pigsty 2.4 MiB postgresql-16-pg-warren_0.8.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_warren_15 0.8.0 el8.x86_64 pigsty 3.0 MiB pg_warren_15-0.8.0-1PGSTY.el8.x86_64.rpm
pg_warren_15 0.8.0 el8.aarch64 pigsty 2.4 MiB pg_warren_15-0.8.0-1PGSTY.el8.aarch64.rpm
pg_warren_15 0.8.0 el9.x86_64 pigsty 2.9 MiB pg_warren_15-0.8.0-1PGSTY.el9.x86_64.rpm
pg_warren_15 0.8.0 el9.aarch64 pigsty 2.6 MiB pg_warren_15-0.8.0-1PGSTY.el9.aarch64.rpm
pg_warren_15 0.8.0 el10.x86_64 pigsty 2.9 MiB pg_warren_15-0.8.0-1PGSTY.el10.x86_64.rpm
pg_warren_15 0.8.0 el10.aarch64 pigsty 2.6 MiB pg_warren_15-0.8.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-warren 0.8.0 d12.x86_64 pigsty 2.6 MiB postgresql-15-pg-warren_0.8.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-warren 0.8.0 d12.aarch64 pigsty 2.1 MiB postgresql-15-pg-warren_0.8.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-warren 0.8.0 d13.x86_64 pigsty 2.6 MiB postgresql-15-pg-warren_0.8.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-warren 0.8.0 d13.aarch64 pigsty 2.1 MiB postgresql-15-pg-warren_0.8.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-warren 0.8.0 u22.x86_64 pigsty 2.8 MiB postgresql-15-pg-warren_0.8.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-warren 0.8.0 u22.aarch64 pigsty 2.5 MiB postgresql-15-pg-warren_0.8.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-warren 0.8.0 u24.x86_64 pigsty 2.8 MiB postgresql-15-pg-warren_0.8.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-warren 0.8.0 u24.aarch64 pigsty 2.4 MiB postgresql-15-pg-warren_0.8.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-warren 0.8.0 u26.x86_64 pigsty 2.8 MiB postgresql-15-pg-warren_0.8.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-warren 0.8.0 u26.aarch64 pigsty 2.4 MiB postgresql-15-pg-warren_0.8.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_warren;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_warren;		# install via package name, for the active PG version

pig install pg_warren -v 18;   # install for PG 18
pig install pg_warren -v 17;   # install for PG 17
pig install pg_warren -v 16;   # install for PG 16
pig install pg_warren -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pg_warren;

Usage

Sources:

pg_warren 0.8.0 builds versioned adjacency snapshots from ordinary PostgreSQL tables for graph traversal and computation. It supports PostgreSQL 15–18 and keeps graph versions, vectors and their changes within PostgreSQL transactions. Traversal reads a built snapshot; source-table changes require an explicit refresh.

Core Workflow

This is a trusted extension: a role with CREATE privilege on the database can install it. A basic graph needs node and edge queries:

CREATE EXTENSION pg_warren;
CREATE TABLE people (id bigint PRIMARY KEY, name text);
CREATE TABLE follows (src bigint, dst bigint);
INSERT INTO people VALUES (1, 'Ada'), (2, 'Bob'), (3, 'Cy');
INSERT INTO follows VALUES (1, 2), (2, 3);
SELECT warren.create_graph('social',
  'SELECT id FROM public.people', 'SELECT src, dst FROM public.follows');
SELECT warren.refresh('social');
SELECT * FROM warren.bfs('social', ARRAY[1::bigint], 3);
SELECT warren.pagerank('social', 'rank');
SELECT * FROM warren.vector_topk('social', 'rank', 3, NULL::bigint);

The graph stores its source queries. Run warren.refresh after changing the source tables; use warren.info to inspect versions and warren.diff to compare them. Building and promoting versions rolls back with the surrounding transaction.

Traversal and Computation

Interface Purpose
warren.bfs, warren.shortest_path Breadth-first traversal and shortest paths
warren.pagerank, warren.components Rank nodes and find connected components
warren.leiden Detect communities
warren.spmv, warren.gather Compose graph calculations with SQL
warren.vector_topk Read the largest values from a stored vector
warren.shared_cache, warren.backends Inspect shared entries and backend cache usage

Identifier types must agree with the graph. Functions without a node identifier argument may require a type witness such as NULL::bigint. In 0.8.0, PageRank and Leiden use native kernels; they write their results to named vectors.

Memory and Preload

PostgreSQL 17–18 initialize the shared cache on first use. PostgreSQL 15–16 need the following setting and a server restart to share graph data between backends:

shared_preload_libraries = 'pg_warren'

Without preload on PostgreSQL 15–16, graph operations still work using private backend caches. Add the library to any existing preload list.

warren.shared_cache_memory limits the cluster-wide shared cache and takes effect on configuration reload. warren.max_cache_memory, warren.max_compute_memory and warren.max_build_memory limit distinct private-cache, computation and build allocations; they are not one combined memory budget. warren.threads controls computation parallelism. On Linux, shared entries also need sufficient /dev/shm; entries that do not fit fall back to private caches.

Access, Backups and Upgrades

Source queries run as the graph owner with the stored search_path. Use schema-qualified source objects and controlled schemas. Public functions enforce graph access; installation does not grant direct access to private catalog tables.

Dump as a superuser to include graph catalogs, versions and vectors, and restore the required owner/reader roles first. Rebuilding from source tables does not preserve historical graph versions. After installing newer library files, run ALTER EXTENSION pg_warren UPDATE in each database using the extension. Dropping it removes stored graphs. The project remains pre-1.0 and does not maintain graph snapshots incrementally.

表格阅读