Deleting nodes taking forever

Hi Everyone,

I am facing very strange bug in neo4j. I have deleted 100k nodes but for some 20-30 nodes it is taking forever to delete .
i am running below query to delete nodes

MATCH(n:LABEL) with n LIMIT 1000 DETACH DELTE n

Could it be that they have lot of relationships?

2 things that affect the time taken are

  1. Amount of heap required to perform the operation. This depends on how many nodes and relationships are being deleted. For each relationship deleted, you are also changing the node on the other side.

  2. Page cache. If page cache is too low to have all the information in memory, it is taking lot of time to read from disk and commits are gong to disk.

Please check for these 2 things.

I had the similar situation to delete many nodes of high degree. I had to use apoc function like this:
call apoc.periodic.iterate(
"match (n:highDegreeNode)",
"detach delete n",
{batchSize:1, parallel:true}
)
You must test to select batchSize since it takes much time when you delete a single node having many relations.