Unexpected apoc.periodic.iterate behavior

Hi,

I have a query I’m just using to clean my database up before loading some stuff into it. I realize there are other ways to do this, but this seemed fine and convenient for smallish local testing and now I’m seeing some unexpected behavior and just trying to understand it.

The query is:

CALL apoc.periodic.iterate(
'MATCH (n) RETURN n',
'DETACH DELETE n',
{batchSize: 10000, parallel: true}
) YIELD batches, total
RETURN batches, total;

I would expect this to delete all the nodes in my database. It does not. Is there something I’m missing?

While the idea here is correct, there is an issue about returning raw nodes/relationships/paths from the driving query to the batch query.

We recommend that you either rebind the variables in the batch query or pass id()s of nodes and variables and re-MATCH by id before you use them in your batch query. This helps avoid an issue where it doesn’t batch, but executes all in one big transaction, which would defeat the purpose of using the procedure in the first place.