Neo4j Blog

Understanding How Neo4j Cypher Queries are Evaluated

There are many ways to store and manage data within a Neo4j graph database. When Neo4j 2.0 launched late last year we had an entirely new browser experience for interacting with graphs. The graph visualization from the return results of Cypher queries were at the core of the user experience enhancements to the platform.

Knowing how the data is generated, filtered, and processed is tremendously helpful for understanding how to optimize queries for the best performance.

For most users that use the Neo4j browser, this is an ideal experience for learning and designing great graph data models for querying. For applications that require a deeper control over how graphs are stored and queried, the native Java API provides a great deal of benefits. When using the Java API you gain a degree of freedom to tell Neo4j how to query your data.

The Cypher query language, with an innovative SQL-like syntax for graphs, is a declarative query language. That means you tell Neo4j what you want and not how to get it. When you run a Cypher query you are expressing to the graph database what you want from it. In turn, Neo4j maintains a compiler that translates that query into an execution plan that describes a set of data operations, arranged such that data is obtained from the graph and processed sequentially through each operation until a result is generated for the user.

What does an execution plan look like?

The typical approach for interacting with Neo4j involves sending a Cypher query and parameters in a POST request to the Neo4j database server. We call the frameworks or libraries that manage wrappers around the REST API methods of Neo4j from an arbitrary programming language a “driver”. These drivers transport queries and results over the network and Neo4j further translates the declarative syntax of Cypher into an execution plan.

About the Author

Kenny Bastani , Developer Relations

Kenny Bastani is a passionate technology evangelist and and open source software advocate in Silicon Valley. As an enterprise software consultant he has applied a diverse set of skills needed for projects requiring a full stack web developer in agile mode.

As a passionate advocate for the popular graph database Neo4j, Kenny has supported developers from globally recognized companies who have inserted the NoSQL database inside their technology stack. As a passionate blogger and open source contributor, Kenny engages a community of passionate developers who are looking to take advantage of newer graph processing techniques to analyze data.