Neo4j 2.0 Merge with a Unique Performance Limit Error?

Here's the situation: I have a node that has a ContactId property that is set as unique and indexed. Label node: Contact (node: contact {ContactId: 1})

I have another node that looks like this template for Address: (node2: Address {AddressId: 1})

Now I am trying to add a new node that (among other properties includes ContactId (for reference)) (node3: ContactAddress {AddressId: 1, ContactId: 1})

When I run the merge command for each, the time it takes to add a node that contains a property that is set to be unique in another type of node seems to make the process much slower.

ContactAddress node contains only relational properties between Contact and Address nodes. Contact and address nodes contain up to 10 properties. Is this a mistake where Neo4j checks the property key → value →, then node label?

Code and screenshot below:

string strForEach = string.Format("(n in {{{0}}} |  
MERGE (c:{1} {{{2} : n.{2}}}) SET c = n)", propKey, label, PK_Field);

var query = client
            .Cypher
            .ForEach(strForEach)
            .WithParam(propKey, entities.ToList());

Process timings

+1
source share
1 answer

Limit checks are more expensive than just inserts. They also use global restriction locks to prevent multiple inserts.

I saw that you are not using parameters, but replace the line, I really recommend changing this and going with the parameters.

Also, set the node cn triggers again to a limit.

You might want to use the sentence ON CREATE SET MERGE

(n in {nodes} |  
MERGE (c:Label {key : n.key}}) ON CREATE SET c.foo = n.foo, c.bar = n.bar )
0
source

Source: https://habr.com/ru/post/1535449/


All Articles