Reputation: 365
I'm hitting a OutOfMemoryError
when trying to set a property for a large number of nodes in Neo4j using cypher.
The approach I'm using is like this:
MATCH (n:MYLABEL) SET n.num_visits = 0 RETURN count(n)
This works OK when the number of nodes matched is in the 100,000s range, but when it get to the millions of nodes range I hit the OutOfMemoryError problem after a very long delay. What is the best approach to handle this without memory problems and to get the operation to complete relatively quickly?
Upvotes: 1
Views: 114
Reputation: 29167
Try apoc.periodic.iterate
procudere from the APOC library
. For example:
CALL apoc.periodic.iterate (
"MATCH (n:MYLABEL) RETURN n",
"SET n.num_visits = 0",
{
batchSize: 100000,
parallel: true
}
)
Upvotes: 2