What's the difference between these two lines?
call apoc.periodic.iterate("MATCH (n:Nodes) return n", "DETACH DELETE n", {batchSize:10000, iterateList:true})"
call apoc.periodic.commit("match (n:Nodes) limit {limit} detach delete n RETURN count(*)",{limit:10000})
What is the best way to delete lots of nodes?
The procedure apoc.periodic.iterate
takes two queries :
So in your example your match all the Node
of your database, and then you delete them with a batch size of 10000.
The procedure apoc.periodic.commit
takes only one query, and the procedure will execute the query again, and again and again ... tilt its result is 0.
So in your example, you take the first 10000 nodes and delete them. You repeat this behaviour till there is no more Node
in your database.
To resume, both queries give the same result, but not in the same way. The apoc.periodic.iterate
will take a little more RAM than the apoc.periodic.commit
(the procedure needs to build the set of nodes at first), but one good thing with it is that you can use all yours CPU, via the configuration parallel:true
(but be carefull to locks).
If you have a really huge number of nodes to delete, I recommand you to use the apoc.periodic.commit
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With