Failure to add calculated property to 60MM nodes using apoc.periodic.iterate

In another topic, I was given the recommendation to use apoc.periodic.iterate to enable batching for a query that calculates and sets a new property on 60MM Customer nodes. Makes lots of sense, but it's not working and I'd like to understand why.

For smaller numbers of nodes (e.g., low millions) I have verified that the basic MATCH...SET...CASE expression operates as expected. However, for the 60MM nodes using apoc.period.iterate, it never actually sets the new property on a single Customer node. But there's no error in debug.log that explains why.

Any ideas why it would fail? How can I monitor the operation for errors, completion, etc.?

CALL apoc.periodic.iterate(
"MATCH (c:Customer) RETURN c",
"SET c.status = CASE
  WHEN c.spend >= 0 AND c.spend <= 50 THEN 'BRONZE'
  WHEN c.spend >= 51 AND c.spend <= 250 THEN 'SILVER'
  WHEN c.spend >= 251 AND c.spend <= 1000 then 'GOLD'
  ELSE 'PLATINUM'", {batchSize:10000, parallel:true})

Thanks

apoc.periodic.iterate returns some values that might help you with debugging:
add yield committedOperations, failedOperations, failedBatches, errorMessages, failedParams to the end of your cypher and then return them. It might show you what failed. If you were adding relationships in your cypher too, I would have said set parallel:false but that should not cause any problem given your current cypher.

1 Like

I believe you're missing and END in your CASE.

2 Likes

Very helpful. Now I see the problem:

There is no procedure with the name `apoc.periodic.iterate` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

Thank you!

1 Like

For some who have been with neo4j for a while this will have been clear, but for me as a beginner it wasn't :D Oops! So, if you get that error message above, also first check if you have the plug-in installed when using Neo4j Desktop. You can find that by clicking on the area between the Graph Database title and the Start/Stop button. Then a small box opens to the right of it and there you can install the plug-ins.
As I said, maybe quite obvious to some, but I didn't discover and understand it until much later. Maybe it will help someone who is also new to this and comes across this post here :-)