DEV Community

Namsi Lydia
Namsi Lydia

Posted on • Edited on

1

Demystifying Apache Age:Apache Age Architecture and cypher query language

From research Apache Age is an extension of a relational database management system on PostgreSQL that provides an implementation of Cypher, a query language similar to SQL, but optimised for graphs.

in this article we are going to demystify the AGE architecture and also have a deep dive and understanding of the cypher query language

What is Apache AGE architecture and what does it entail?

The Apache AGE architecture is similar to the PostgreSQL architecture and backend. Every component runs on the PostgreSQL transaction cache layer and storage layer. The main components of the Apache AGE architecture are:

1.Query Passing - Parse cypher queries embedded in cypher function calls.Here we implement the grammar for open cypher.

2.Query Transform- Transforms cypher query into query tree that will be attached as a subquery.

3.Planner/Optimizer - Understands some graph operations and produces plan nodes that are related to graph operations.

4.Executor- Executes plan nodes that are related to graph operations

5.Transaction/Cache layer - Cypher queries work with PostgreSQL existing fully transactional system (ACID).

In addition to these components, Apache AGE also includes a number of other features, such as:
Hybrid Queries: This feature allows users to mix and match relational and graph queries in the same statement.
Graph Visualization: This feature provides a way to visualize graph data using a web-based tool.
Graph Analytics: This feature provides a number of graph algorithms that can be used to analyze graph data.

The deeper workings of Apache AGE are based on the openCypher query language. openCypher is a graph query language that is designed to be compatible with a wide range of graph databases. Apache AGE uses openCypher to provide a unified way to query both relational and graph data.

When a user submits a Cypher query to Apache AGE, the query is first parsed by the query parser. The query parser converts the query into a query tree, which is a data structure that represents the logical structure of the query.

The query tree is then passed to the query transform, which transforms the query tree into a form that can be executed by the planner/optimizer. The planner/optimizer generates an execution plan for the query, which is a sequence of steps that will be used to execute the query.

The execution plan is then passed to the executor, which executes the query plan. The executor interacts with the PostgreSQL database to retrieve the data that is needed to satisfy the query.

Basic structure and implementation of opencypher language:

Example 1:Creating a simple graph in Age:

Syntax:
cypher(graph_name, query_string, parameters)

In this example this returns a set of records

Brief description:
graph_name The target graph for the Cypher query.
query_string The Cypher query to be executed.
parameters An optional map of parameters used for Prepared Statements. Default is NULL.

With this small illustration you can create your own graph with ease and many more examples.

For more detail review of the opencypher query language and how to work with Apache AGE you can follow the following link
to their documentation

Link:[https://age.apache.org/age-manual/master/index.html]

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay