Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-10-2019 03:39 AM
I use this query to relate some nodes between other nodes that the user has.
The problem I have is that when a lot of relationships are created, it takes longer and longer.
I'm trying to find the bottleneck here but I'm missing why or what.
If you can help me i would appreciate.
TL;DR here is my query to be optimized
WITH
[
{ "sender":123, "target":124, "label":"fruit", "bidirectional":true},
{ "sender":123, "target":125, "label":"vegetable", "bidirectional":false}
] as input
MATCH (s) <-[:HAS]-(user:User {author:"me"})-[:HAS]->(t)
UNWIND input as relationship
WITH s,t,relationship
WHERE ID(s) = relationship.sender AND ID(t) = relationship.target
MERGE (s)-[:HAS {label: relationship.label}]->(t)
WITH s,t,relationship
WHERE relationship.bidirectional = true
MERGE (t)-[:HAS {label: relationship.label}]->(s)
The WITH clause is replaced by parameters I send to the query, input in my original query is $input.
I found this link interesting (https://stackoverflow.com/questions/30930311/how-can-i-optimise-a-neo4j-merge-query-on-a-node-with-m...)
Thank you
04-11-2019 02:56 PM
We can help, but could you PROFILE an execution of the query and (after expanding all elements) attach the profile plan here?
All the sessions of the conference are now available online