Query tuning
Neo4j aims to execute queries as fast as possible. However, when optimizing for maximum query execution performance, it may be helpful to rephrase queries using knowledge about the domain and the application.
This section contains information about how to tune queries using different strategies.
For information about changing the runtime of a query, see the page about Cypher® runtime concepts.
General recommendations
The overall goal of manual query performance optimization is to ensure that only necessary data is retrieved from the graph.
Queries should aim to filter data as early as possible in order to reduce the amount of work that has to be done in the later stages of query execution. This also applies to what gets returned: returning whole nodes and relationships ought to be avoided in favour of selecting and returning only the data that is needed. You should also make sure to set an upper limit on variable length patterns, so they don’t cover larger portions of the dataset than needed.
Each Cypher query gets optimized and transformed into an execution plan by the Cypher query planner. To minimize the resources used for this, try to use parameters instead of literals when possible. This allows Cypher to re-use queries instead of having to parse and build new execution plans.
To read more about the execution plan operators mentioned in this section, see Operators.
Was this page helpful?