I have this cypher query to insert 10,000 node. This works nice.
LOAD CSV WITH HEADERS FROM "file:///persons.csv" AS csv
MERGE (u2:User {mobileNumber: csv.mobileNumber})
ON CREATE SET u2.memberType = csv.memberType
ON CREATE SET u2.accountId = csv.accountId
ON CREATE SET u2.accountType = csv.accountType
ON CREATE SET u2.createdAt = csv.createdAt
SET u2.updatedAt = csv.updatedAt
Now 20 new node creates [:contact] relationship with some other nodes that already exist. My query creates 20,000 extra nodes and runs very slow. I know merge has some issue with duplication. How can I make this code run faster?
LOAD CSV WITH HEADERS FROM "file:///phonebook.csv" AS csv
MERGE (:User{mobileNubmer: csv.ownerMobileNumber})-[c:CONTACT]->
(:User{mobileNubmer:csv.contactMobileNumber})
ON CREATE SET c.createdAt = csv.createdAt
ON MATCH set c.previousIsActive =
csv.previousIsActive
SET c.name = csv.name
SET c.relationship = csv.relationship
SET c.isActive = csv.isActive
SET c.updatedAt = csv.updatedAt;