Query Runtime and Replanning
This guide describes improvements made for query replanning in Neo4j 4.1.
You should be familiar with how queries work in Neo4j
In Neo4j 4.0, Cypher introduced the pipelined runtime to optimize query planning. In 4.1, we have added even more READ operators to the pipelined Cypher runtime. These new operators include:
That brings to a total of operators for pipelined runtime to 48 that we have implemented. We have just 8 operators that need to be implemented to fully support read in the pipelined runtime.
Pipelined read operators have improved READ performance by 11-50% in 4.1.
If you have extremely small queries (micro-second level), using slotted runtime will still be faster than pipelined.
In 4.0, Cypher had these options:
CYPHER x.y <query>
Where you could specify, for example 4.0 or 3.5 for the version of Cypher.
CYPHER runtime=<runtime-type> <query>
Where the options for <runtime-type> were:
interpreted (slower, used in Community Edition)
slotted (more optimized interpreted)
pipelined (replaced compiled in 3.x; more optimizations)
In 4.1, Cypher has added a
replan option to help you control if the query will be recompiled.
Sometimes recompilation is desired, especially if the statistics that affect query planning have changed.
However, there are also times when you do not want the plan to change because you are measuring queries that you have previously cached and you do not want the expense of recompilation.
CYPHER replan=<replan-type> <query>
Where the options for <replan-type> are:
force (to recompile the query, whether it is in the cache or not)
skip (recompile only if the query is not in the cache)
In general, if you want to force a replan, then you would do something like this:
CYPHER replan=force EXPLAIN <query>
This will cause the query to be recompiled and placed in the cache with the latest statistics.
Are you struggling?If you need help with any of the information contained on this page, you can reach out to other members of our community. You can ask questions in the Cypher category on the Neo4j Community Site.
Was this page helpful?