Reputation: 1
Today I have create 591,113 nodes in my neo4j. Then I want create relationships on them using following code:
MATCH (A), (B)
WHERE A.value = B.value
CREATE (A)-[:SameValue]->(B)
But this took me for hours(and I have to terminate it before it finish). And I want to ask how to create relationship on a big amount of nodes fast?
Upvotes: 0
Views: 632
Reputation: 10856
Do you have indexes on the value
properties?
This also might work better (still, indexes are important):
MATCH (a:A) WITH a
MATCH (b:B {value: a.value})
CREATE a-[:SameValue]-b
Upvotes: 3
Reputation: 3739
You could try:
MATCH (a:UseLabels)
WITH a
MATCH (b:UseLabels{value:a.value})
CREATE (a)-[:SameValue]->(b)
It only matches values that match and avoid the cartesian product.
Upvotes: 3