DEV Community

Cover image for How Data is Stored - The Internals of Apache AGE
Wendel Fernandes de Lana
Wendel Fernandes de Lana

Posted on • Updated on

How Data is Stored - The Internals of Apache AGE

Introduction

In this article I will give an introduction to the internals of Apache AGE, specifically how data is stored in AGE.

Prerequisites

A basic knowledge of PostgreSQL or any other Relational Database Management System (RDBMS), including an understanding of tables, schemas, and commonly used SQL queries such as SELECT, INSERT, DELETE, and UPDATE, is essential. Additionally, proficiency in JSON (JavaScript Object Notation) is also necessary.

How Data is Stored

Apache AGE uses a separate namespace in PostgreSQL for each individual graph, with the data for each graph being stored in the table ag_catalog.ag_graph.

Executing SELECT oid, * FROM ag_catalog.ag_graph, showing all graphs

  • oid - PostgreSQL identifier for the graph

  • name - The graph name

  • namespace - The schema name

When creating a graph, it also creates 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. Vertices and edges in AGE are stored as rows in PostgreSQL tables, with each row representing a single vertex or edge in the graph.

A label is generally a user-defined string that is assigned to vertices and edges in the graph to describe their type or category. The data for each label is stored in the table ag_label.

Executing SELECT oid, * FROM ag_catalog.ag_label, showing all labels

  • oid - Unique PostgreSQL identifier per label

  • name - The label name

  • graph - The oid of the graph to which this label belongs

  • id - The id for the label, unique per graph

  • kind - The type of label as v stands for vertex and e for edge

  • relation - The schema-qualified table name for the label

The data for all vertices and edges in a graph is stored at graph_name._ag_label_vertex and graph_name._ag_label_edge.
SELECT on tables _ag_label_vertex and _ag_label_edge It's possible to see the data for all vertices or edges under a specific label using graph_name."Label".

Apache AGE repository: https://github.com/apache/age
Apache AGE website: https://age.apache.org

Top comments (0)