Execution plans and query tuning

Cypher® queries are executed according to a particular execution plan. The execution plan consists of a binary tree of operators, with information about the step-by-step execution of a query, and it may differ depending on which runtime the query uses. Apart from selecting a different runtime, there are numerous other ways in which a query can be tuned.

More information about each of these topics can be found in the following sections:

Note on PROFILE and EXPLAIN

The queries in this section are often prepended with either PROFILE or EXPLAIN. Both produce an execution plan, but there are important differences:

EXPLAIN

If you want to see the execution plan but not run the query, prepend your Cypher statement with EXPLAIN. The statement will always return an empty result and make no changes to the database.

PROFILE

If you want to run the query and see which operators are doing most of the work, use PROFILE. This will run your query and keep track of how many rows pass through each operator, and how much each operator needs to interact with the storage layer to retrieve the necessary data. Note that profiling your query uses more resources, so you should not profile unless you are actively working on a query.