Cypher query tuningIntroduced in 6.0
Default Cypher® parameters are optimized for the general use case. However, the Spark connector supports all the query tuning options described in the Cypher manual.
|
All the examples in this page assume that the |
Specify the Cypher versionIntroduced in 6.0
You can change the Cypher version using the cypher.version option.
val df = spark.read
.format("org.neo4j.spark.DataSource")
.option("query", "MATCH (o: Object) RETURN o")
.option("cypher.version", "25")
.load()
df = (
spark.read.format("org.neo4j.spark.DataSource")
.option("query", "MATCH (o: Object) RETURN o")
.option("cypher.version", "25")
.load()
)
Equivalent Cypher query
CYPHER 25
MATCH (o: Object) RETURN o
Add query tuning parametersIntroduced in 6.0
You can add any tuning option described in the Cypher manual using the cypher.tuning prefix in a Spark option.
All the tuning options are added to the Cypher query as CYPHER preambles.
val df = spark.read
.format("org.neo4j.spark.DataSource")
.option("query", "MATCH (o: Object) RETURN o")
.option("cypher.tuning.runtime", "parallel")
.load()
df = (
spark.read.format("org.neo4j.spark.DataSource")
.option("query", "MATCH (o: Object) RETURN o")
.option("cypher.tuning.runtime", "parallel")
.load()
)
Equivalent Cypher query
CYPHER runtime=parallel
MATCH (o: Object) RETURN o
You are also free to add multiple parameters this way, simply add them separately like so.
val df = spark.read
.format("org.neo4j.spark.DataSource")
.option("query", "MATCH (o: Object) RETURN o")
.option("cypher.tuning.runtime", "parallel")
.option("cypher.tuning.operatorEngine", "interpreted")
.load()
df = (
spark.read.format("org.neo4j.spark.DataSource")
.option("query", "MATCH (o: Object) RETURN o")
.option("cypher.tuning.runtime", "parallel")
.option("cypher.tuning.operatorEngine", "interpreted")
.load()
)
Equivalent Cypher query
CYPHER runtime=parallel operatorEngine=interpreted
MATCH (o: Object) RETURN o
Tuning feature compatibility
In the above examples we illustrated using custom read query for the sake of simplicity. While the examples above show how to tune preambles and change the Cypher version for read queries, the same features can be used for writing as well as other operations.
| When using | cypher.version |
cypher.tuning |
|---|---|---|
|
Reads & writes |
Reads & writes |
|
Reads & writes |
Reads & writes |
|
Reads & writes |
Reads & writes |
|
Only for reads |
No tuning allowed |