age
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
age | 1.7.0 | FEAT | Apache-2.0 | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2700 | age | No | Yes | No | Yes | No | No | ag_catalog |
| Related | pg_graphql rum pg_jsonschema jsquery ltree http pg_net citus |
|---|
pg18/17 = 1.7.0
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | MIXED | 1.7.0 | 1817161514 | age | - |
| RPM | PIGSTY | 1.7.0 | 1817161514 | apache-age_$v | - |
| DEB | PGDG | 1.7.0 | 1817161514 | postgresql-$v-age | - |
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
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;
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.