Multithreading in Neo4j: Is it more efficient to use hard coded ids or a where condition if I want to use multi threading?

37 views Asked by At

I am currently working on a Spring Data Neo4j Project. My problem is that I have to check if a node with a specific value in a specific property already exists. If that is the case, then I use that node for my transaction, otherwise I generate a new node and use the newly generated one. I was wondering what would be more efficient: Should I make the property to the id of the node, as it is the deciding factor, whether a new node gets created or not or should I check first, whether the node exists with a where condition.

In my opinion the id way would be more efficient. However, I have to save a large number of nodes and I want to use multithreading. And I am pretty sure that there will be race conditions with the id approach. But I also think that there will occur race conditions if I check with a where condition first. However, I am not really sure. So my other question would be, how can I implement multi-threading and guarantee that no race coniditons occur with my transaction, where I check the existence of a node first.

0

There are 0 answers