pg_graph
alohadb · AlohaDB: Property-graph traversal and algorithms over ordinary tables
Overview
PostgreSQL · 18
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
pg_graph 1.3 provides property-graph traversal and algorithms over ordinary tables. This preview module is scoped to the PostgreSQL 18 fork in AlohaDB 21.10.0; stock PostgreSQL compatibility is not established.
Workflow
Installation requires a superuser; function use also requires the appropriate object privileges.
Operational boundaries
graph_add_vertex_label and graph_add_edge_label bind existing tables and can install foreign-key/check constraints. graph_bfs, graph_pagerank and graph_sample_neighbors expose traversal, ranking and sampling; temporal columns enable as_of selection. Table privileges and RLS apply to graph reads. Graph algorithms load edges into backend memory; pg_graph.max_edges bounds that load. Validate existing data before enabling constraints and review the cost of large graphs.
This module corresponds to the former upstream name alohadb_graph. Follow AlohaDB’s cluster/object conversion procedure and do not substitute an unrelated implementation with a similar name. Rehearse dependencies, privileges and backup restoration before upgrades.
Read-only Cypher
Version 1.1 adds graph_cypher(graph, query, params, as_of), returning one JSONB object per result row, and graph_cypher_sql(graph, query, params) to inspect translated SQL. The supported read-only subset includes MATCH, OPTIONAL MATCH, WHERE, WITH, UNWIND and RETURN; it is not a complete Cypher engine or a graph-write API. Use JSONB parameters for values and register vertex/edge labels before querying. as_of filters temporal edge labels, while ordinary table privileges and RLS still apply.
The new SQL helper layer uses PL/pgSQL. After installing matching files, existing installations can run ALTER EXTENSION pg_graph UPDATE TO '1.1'; through the supplied 1.0-to-1.1 script. Back up and rehearse dependency changes first.
Writes, Paths and Procedures in 1.3
Read-only queries remain in graph_cypher; graph_cypher_exec is the separate volatile write entry point for CREATE, MERGE, SET, REMOVE, DELETE and DETACH DELETE. Writes execute ordinary table operations as the caller, with privileges, RLS, constraints and triggers applied. Version 1.2 adds shortest paths; 1.3 adds FOREACH, additional functions and CALL procedures for supported algorithms and catalog inspection. This remains a defined subset of Cypher.
Use registered labels and parameters for values. Review memory and traversal bounds before large graph operations. Install matching binaries and the supplied sequential 1.1-to-1.2-to-1.3 SQL updates: