As Apache AGE is an extension to PostgreSQL. I am curious about how and where the data of vertices (nodes) and edges are stored in Apache AGE.
Does it use PostgreSQL for this? If yes, then how.
Question posted in PostgreSQL
The official documentation can be found here.
The official documentation can be found here.
2
Answers
Yes, the nodes and edges get stored in separate tables. You can see the full list of tables if you do:
SELECT * FROM information_schema.tables;
You can see the node/edge data if you do:
SELECT * FROM <graph_name>.<node/edge_label> LIMIT 10;
If you are unsure of the name you gave your graph, you can do:
SELECT * FROM ag_catalog.ag_graph
… to get a full list of graphs that you’ve stored using AGE.
Here are examples of two different tables in a test data set that I use comprised of Airports and defined airline routes between Airports. The first table is of vertices where each Airport is a vertex:
And then I have edges that define the routes between airports:
A view of the first 5 airports:
A view of the first 5 routes:
When you create a graph with
SELECT * FROM create_graph('ag_graph')
it adds it’s name and namespace toag_catalog.ag_graph
, and also create two tables within this namespace:_ag_label_vertex
and_ag_label_edge
. These will be the parent tables of any new vertex or edge label you create.So then, if you want to see all the vertices or edges in your graph, you can execute the following queries:
Then, whenever you add a vertex or edge label, it is going to store them in a new table for the label, like
"ag_graph"."new_label"
which will inherit from one of these parent labels. Because of this inheritance system which postgres allows, querying for the parent label tables also retrieves the child label tables.