AndyP1970
AndyP1970

Reputation: 205

Neo4j 3.0.1 DETACH DELETE Hangs

Trying to clear one type of node for a monthly purge operation. Running:

MATCH (s:SeriesData) DETACH DELETE s

There about 900,000 nodes to be deleted, each with only one relationship. Running local DB on Windows 10, Intel i7 processor, fast SSD and 32GB of RAM. Each node is small with just an UID and a float property. Neo4j consumes >90% of the CPU and the RAM slowly grows to over 10GB. This state stays constant for over 20 minutes and never completes. No errors are given. I am assuming it is a bug since the database can handle billions of nodes, so deleting 900k should be an easy task.

Any ideas as to the issue. I know I can break it down into chunks with a LIMIT clause, but I would prefer to keep the code clean. Does Neo4j have a PERIODIC COMMIT functionality for deleting?

Upvotes: 2

Views: 974

Answers (2)

Michael Hunger
Michael Hunger

Reputation: 41686

It's running out of memory for the temporary transaction state.

Make either sure that you have enough heap configured, can you check your debug.log how much heap it actually is used?

For 1M nodes + 1M rels about 4G-8G should be enough.

you can also count how much is actually deleted by running:

MATCH (s:SeriesData)
RETURN sum(size((s)--()) + 1) as nodes_and_rels

Upvotes: 0

William Lyon
William Lyon

Reputation: 8546

If you are using Neo4j 3.0 have a look at the job management procedures in the apoc procedures library. There is a procedure that gives you periodic commit functionality:

CALL apoc.periodic.commit("
    MATCH (s:SeriesData) 
    WITH s LIMIT {num} 
    DETACH DELETE s 
    RETURN count(*)", {num: 1000})

Upvotes: 4

Related Questions