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})


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.


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