age
age : AGE graph database extension
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2700 | age
|
age
|
1.7.0 |
FEAT
|
Apache-2.0
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sLd--
|
No
|
Yes
|
Yes
|
Yes
|
no
|
no
|
| Relationships | |
|---|---|
| Schemas | ag_catalog |
| See Also | pg_graphql
rum
pg_jsonschema
jsquery
ltree
http
pg_net
citus
|
pg18/17 = 1.7.0
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED
|
1.7.0 |
18
17
16
15
14
|
age |
- |
| RPM | PIGSTY
|
1.7.0 |
18
17
16
15
14
|
apache-age_$v |
- |
| DEB | PGDG
|
1.7.0 |
18
17
16
15
14
|
postgresql-$v-age |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
el8.aarch64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
el9.x86_64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
el9.aarch64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
el10.x86_64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
el10.aarch64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
PIGSTY 1.6.0
|
d12.x86_64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
d12.aarch64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
d13.x86_64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
d13.aarch64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
u22.x86_64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
u22.aarch64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
u24.x86_64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
u24.aarch64
|
PIGSTY 1.7.0
|
PIGSTY 1.7.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
PGDG 1.6.0
|
Source
pig build pkg age; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install age; # install via package name, for the active PG version
pig install age -v 18; # install for PG 18
pig install age -v 17; # install for PG 17
pig install age -v 16; # install for PG 16
pig install age -v 15; # install for PG 15
pig install age -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'age';Create this extension with:
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;