One of the root causes of the poor query performance is due to running many cypher statements with literal values.
This leads to inefficient cypher as there is currently no use of parameters and as a result you don't benefit fully from the execution plan cache that would occur otherwise.
Consider that if you issue 10 cypher queries identical in form but with different literals you do not get the most optimal cache and reuse of memory and instead incur multiple times parsing and generating an execution plan.
For example, consider the below query:
match (tg:asset) where tg.name = "ABC123"
merge (tg)<-[:TAG_OF]-(z1:tag{name:"/DATA01/"+tg.name+"/Top_DOOR"})
merge (tg)<-[:TAG_OF]-(z2:tag{name:"/DATA01"+tg.name+"/Data_Vault"})
. . .
The above query can be rewritten as follows:
MATCH (tg:asset) WHERE tg.name = $gtName
WITH tg
UNWIND $tags as tag
MERGE (tg)<-[:TAG_OF]-(:tag {name: tag.name})
Comments
0 comments
Article is closed for comments.