Updating all nodes in a graph

Viewed 1133

I have a Neo4J DB with ~250M nodes (community edition, v2.3.2) and I need to run a query that will iterate all nodes and update a property. It's not a part of my routine queries but a one-time maintenance task that I have to run.

I could easily express it with Cypher, but it looks like Neo4J is trying to hold in memory all nodes and then perform my SET operation, causing it to run out of memory, and even worse - put the whole JVM into a constant GC loop. Any chance I can make it run as in a foreach loop, operating on one node at a time?

My Cypher query will be:

MATCH (n:MyNode) WHERE NOT HAS (n.newColumn) SET n.newColumn=n.c1+n.c2

I don't mind if it runs for a lot of time, just that it won't crash the server itself. I'm also open to use other APIs if Cypher is not the best tool for the task.

And in more general - what's the best practice when you do need to run a "full-graph-scan" query on your Neo4J DB?

Thanks!

1 Answers
Related