neo4j Nodes Deleted (but not Actually)

44 views Asked by At

I would like to delete all the nodes of a certain label by executing

match (P:ALabel) delete P;

This returns the comment "No data returned." It also states how many Nodes deleted, and how long it took (5767 ms). However, the shell seems to stop responding after this, and I am unable to execute any other commands.

I also used this command, encouraged from this answer:

match (n:ALabel)
optional match (n)-[r]-()
delete n, r;

Executing this command took slightly longer (16929 ms). It still does not return.

1

There are 1 answers

0
Stefan Armbruster On BEST ANSWER

Depending on the amount of changes you need to choose an appropriate transaction size, otherwise you'll see excessive garbage collections and/or OOM exceptions. Use the LIMIT clause and return back the number of deleted nodes. Run this statement multiple times until 0 is returned:

match (n:ALabel)
with n limit 5000
optional match (n)-[r]-()
delete n,r 
return count(distinct n)

Here the batch size is 5000 nodes.