Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-28-2020 09:59 PM
Hi all,
I realize when deleting nodes, there is no information returned like number of deleted nodes or even number of delete relationships.
Example query
CALL apoc.periodic.iterate('MATCH (u:User)
WHERE u.name IN $data
OPTIONAL MATCH (u)-[:OWNS]->(c:Car)
RETURN u, c',
'DETACH DELETE u, c', {batchSize:1000, params:{data:$data}})
In the above example, I want to return the number of user nodes deleted and number of car nodes deleted if it is possible with the additional info I get from using apoc.periodic.iterate
Thanks in advance.
Solved! Go to Solution.
07-29-2020 05:04 AM
Hello @tarendran.vivekanand
One solution is to count nodes before and count after and compute the difference
Regards,
Cobra
07-29-2020 01:48 AM
You can YIELD
the total
value from the procedure call to get the total number of rows:
CALL apoc.periodic.iterate('MATCH (u:User)
WHERE u.name IN $data
OPTIONAL MATCH (u)-[:OWNS]->(c:Car)
RETURN u, c',
'DETACH DELETE u, c', {batchSize:1000, params:{data:$data}})
YIELD total
RETURN total
You can yield any of the values below:
(batches :: INTEGER?, total :: INTEGER?, timeTaken :: INTEGER?, committedOperations :: INTEGER?, failedOperations :: INTEGER?, failedBatches :: INTEGER?, retries :: INTEGER?, errorMessages :: MAP?, batch :: MAP?, operations :: MAP?, wasTerminated :: BOOLEAN?, failedParams :: MAP?)
07-29-2020 02:16 AM
Hello @adam.cowley
Thanks for the reply
Based on your reply,
It only returns the total rows but doesn't return the total number of nodes deleted. In the query I have also match the user to car this is a one-to-many relationship thus I can be deleting a lot more nodes then rows. I would also like to know if possible the number of nodes deleted for each (i.e. number of nodes deleted for user and number of nodes deleted for cars).
07-29-2020 05:04 AM
Hello @tarendran.vivekanand
One solution is to count nodes before and count after and compute the difference
Regards,
Cobra
All the sessions of the conference are now available online