age

AGE graph database extension

Overview

PackageVersionCategoryLicenseLanguage
age1.7.0FEATApache-2.0C
IDExtensionBinLibLoadCreateTrustRelocSchema
2700ageNoYesNoYesNoNoag_catalog
Relatedpg_graphql rum pg_jsonschema jsquery ltree http pg_net citus

pg18/17 = 1.7.0

Version

TypeRepoVersionPG VerPackageDeps
EXTMIXED1.7.01817161514age-
RPMPIGSTY1.7.01817161514apache-age_$v-
DEBPGDG1.7.01817161514postgresql-$v-age-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
u22.x86_64
u22.aarch64
u24.x86_64
u24.aarch64

Build

You can build the RPM / DEB packages for age using pig build:

pig build pkg age         # build RPM / DEB packages

Install

You can install age directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

pig install age;          # Install for current active PG version
pig ext install -y age -v 18  # PG 18
pig ext install -y age -v 17  # PG 17
pig ext install -y age -v 16  # PG 16
pig ext install -y age -v 15  # PG 15
pig ext install -y age -v 14  # PG 14
dnf install -y apache-age_18       # PG 18
dnf install -y apache-age_17       # PG 17
dnf install -y apache-age_16       # PG 16
dnf install -y apache-age_15       # PG 15
dnf install -y apache-age_14       # PG 14
apt install -y postgresql-18-age   # PG 18
apt install -y postgresql-17-age   # PG 17
apt install -y postgresql-16-age   # PG 16
apt install -y postgresql-15-age   # PG 15
apt install -y postgresql-14-age   # PG 14

Create Extension:

CREATE EXTENSION age;

Usage

age: AGE graph database extension

Apache AGE brings graph database capabilities to PostgreSQL using the openCypher query language. It enables hybrid querying that combines SQL and Cypher, property indexes on vertices and edges, and the ability to query multiple graphs.

Each session requires loading the extension:

CREATE EXTENSION age;
LOAD 'age';
SET search_path = ag_catalog, "$user", public;

Graph Operations

Create a graph:

SELECT create_graph('my_graph');

Create vertices:

SELECT * FROM cypher('my_graph', $$
    CREATE (:Person {name: 'Alice', age: 30})
$$) AS (v agtype);

SELECT * FROM cypher('my_graph', $$
    CREATE (:Person {name: 'Bob', age: 25})
$$) AS (v agtype);

Create edges:

SELECT * FROM cypher('my_graph', $$
    MATCH (a:Person), (b:Person)
    WHERE a.name = 'Alice' AND b.name = 'Bob'
    CREATE (a)-[e:KNOWS {since: 2020}]->(b)
    RETURN e
$$) AS (e agtype);

Query the graph:

SELECT * FROM cypher('my_graph', $$
    MATCH (v)-[r]-(v2)
    RETURN v, r, v2
$$) AS (v agtype, r agtype, v2 agtype);

Cypher Query Features

AGE supports standard Cypher clauses including MATCH, CREATE, SET, DELETE, RETURN, WITH, WHERE, ORDER BY, SKIP, and LIMIT. Data is stored using the agtype data type, which extends JSON with graph-specific types for vertices, edges, and paths.

Pattern matching with variable-length paths:

SELECT * FROM cypher('my_graph', $$
    MATCH (a:Person)-[:KNOWS*1..3]->(b:Person)
    RETURN a.name, b.name
$$) AS (source agtype, target agtype);

Hybrid SQL/Cypher queries allow joining graph results with relational tables:

SELECT t.*, c.* FROM my_table t
JOIN cypher('my_graph', $$
    MATCH (n:Person) RETURN n.name, id(n)
$$) AS c(name agtype, id agtype)
ON t.graph_id = c.id;

Last Modified 2026-03-12: add pg extension catalog (95749bf)