postgresqlgraph-databasesapache-age

How and where data is actually stored in Apache AGE?


As Apache AGE is an extension to PostgreSQL. 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 can I check the tables where my actual data is getting stored.


Solution

  • 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:

    postgresDB=# \d airroutes.airport
                                                                        Table "airroutes.airport"
       Column   |  Type   | Collation | Nullable |                                                      Default                                                      
    ------------+---------+-----------+----------+-------------------------------------------------------------------------------------------------------------------
     id         | graphid |           | not null | _graphid((_label_id('airroutes'::name, 'airport'::name))::integer, nextval('airroutes.airport_id_seq'::regclass))
     properties | agtype  |           | not null | agtype_build_map()
    Indexes:
        "airport_prop_idx" btree (agtype_access_operator(VARIADIC ARRAY[properties, '"code"'::agtype]))
    Inherits: airroutes._ag_label_vertex
    

    And then I have edges that define the routes between airports:

    postgresDB=# \d airroutes.route
                                                                       Table "airroutes.route"
       Column   |  Type   | Collation | Nullable |                                                    Default                                                    
    ------------+---------+-----------+----------+---------------------------------------------------------------------------------------------------------------
     id         | graphid |           | not null | _graphid((_label_id('airroutes'::name, 'route'::name))::integer, nextval('airroutes.route_id_seq'::regclass))
     start_id   | graphid |           | not null | 
     end_id     | graphid |           | not null | 
     properties | agtype  |           | not null | agtype_build_map()
    Inherits: airroutes._ag_label_edge
    

    A view of the first 5 airports:

    postgresDB=# SELECT * FROM airroutes.airport LIMIT 5;
           id        |                                                                                                                                  properties                                                                                                                    
                   
    -----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     844424930131969 | {"id": "1", "lat": "33.63669968", "lon": "-84.42810059", "city": "Atlanta", "code": "ATL", "desc": "Hartsfield - Jackson Atlanta International Airport", "elev": "1026", "icao": "KATL", "__id__": 1, "region": "US-GA", "country": "US", "longest": "12390", "runways": "5"}
     844424930131970 | {"id": "2", "lat": "61.17440033", "lon": "-149.9960022", "city": "Anchorage", "code": "ANC", "desc": "Anchorage Ted Stevens", "elev": "151", "icao": "PANC", "__id__": 2, "region": "US-AK", "country": "US", "longest": "12400", "runways": "3"}
     844424930131971 | {"id": "3", "lat": "30.19449997", "lon": "-97.66989899", "city": "Austin", "code": "AUS", "desc": "Austin Bergstrom International Airport", "elev": "542", "icao": "KAUS", "__id__": 3, "region": "US-TX", "country": "US", "longest": "12250", "runways": "2"}
     844424930131972 | {"id": "4", "lat": "36.12450027", "lon": "-86.67819977", "city": "Nashville", "code": "BNA", "desc": "Nashville International Airport", "elev": "599", "icao": "KBNA", "__id__": 4, "region": "US-TN", "country": "US", "longest": "11030", "runways": "4"}
     844424930131973 | {"id": "5", "lat": "42.36429977", "lon": "-71.00520325", "city": "Boston", "code": "BOS", "desc": "Boston Logan", "elev": "19", "icao": "KBOS", "__id__": 5, "region": "US-MA", "country": "US", "longest": "10083", "runways": "6"}
    (5 rows)
    

    A view of the first 5 routes:

    postgresDB=# SELECT * FROM airroutes.route LIMIT 5;
            id        |    start_id     |     end_id      |                            properties                             
    ------------------+-----------------+-----------------+-------------------------------------------------------------------
     1688849860263937 | 844424930131969 | 844424930131971 | {"dist": "809", "route_id": "3749", "end_vertex_type": "airport"}
     1688849860263938 | 844424930131969 | 844424930131972 | {"dist": "214", "route_id": "3750", "end_vertex_type": "airport"}
     1688849860263939 | 844424930131969 | 844424930131973 | {"dist": "945", "route_id": "3751", "end_vertex_type": "airport"}
     1688849860263940 | 844424930131969 | 844424930131974 | {"dist": "576", "route_id": "3752", "end_vertex_type": "airport"}
     1688849860263941 | 844424930131969 | 844424930131975 | {"dist": "546", "route_id": "3753", "end_vertex_type": "airport"}
    (5 rows)