Use the APOC apoc.periodic.iterate procedure in Neo4j for large-scale batch graph mutations without memory exhaustion

domain: neo4j.com/docs/apoc/current · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Install APOC Core plugin and confirm availability: CALL apoc.help('periodic.iterate') YIELD name, text RETURN name, text
  2. Call apoc.periodic.iterate with a data-fetching Cypher as the first argument and a mutation Cypher as the second, passing batchSize to control commit frequency: CALL apoc.periodic.iterate('MATCH (n:OldNode) RETURN n', 'SET n:NewLabel REMOVE n:OldNode', {batchSize: 1000, parallel: false})
  3. Use parallel: true only when the mutation Cypher operates on disjoint node sets to avoid deadlocks; for connected graph mutations keep parallel: false
  4. Capture the return value to check for errors: YIELD batches, total, timeTaken, committedOperations, failedOperations, errorMessages
  5. For very large graphs set iterateList: true (default) to pass a batch list to the inner query rather than re-running the outer query per batch, which reduces planning overhead
  6. Monitor progress by periodically running CALL apoc.periodic.list() to see running jobs

Known gotchas

Related routes

Run Memgraph MAGE graph algorithms (PageRank, community detection) via Cypher CALL on an in-memory graph
memgraph.com/docs/advanced-algorithms · 6 steps · unrated
run large-scale account mutations asynchronously via google ads api batchjobservice
developers.google.com/google-ads/api · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans