Reputation: 190
I have 500 nodes each of which gonna has a relationship to a specific node. Performance wise, Is it better to find all 500 nodes and create all relationships in one query or do it separately?
From my tests I can tell doing it in one query seems to be quicker, but I don't know in case of an error, how to find where the query broke and which parts are done.
Upvotes: 0
Views: 25
Reputation: 67044
If all 500 nodes need to form relationships to the same specific node (let's call it x
), then doing them all in a single query would definitely be faster, since you'd only need to find x
just once -- not 500 times.
neo4j is transactional, and every operation in the same transaction must succeed or all of them will be rolled back. If you create all 500 relationships in a single Cypher statement (which will be handled within a single transaction), then you do not have to worry about errors causing inconsistencies in your DB.
Upvotes: 1