Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neo4j delete graph out of memory

I'm using neo4j on a linux machine 16G memory and I'm trying to delete all the graph . it has 11353056 relationship vs 19900 nodes. when I run Match (n) detach delete n after loading for a while I get thee out of memory error .

how can I delete the graph ? should I proceed by deleting the relationships and then delete the nodes to prevent that problem ?

like image 250
Muna arr Avatar asked Sep 10 '25 19:09

Muna arr


2 Answers

Do like this to remove records with a limitation:

MATCH (n)
WITH n LIMIT 10000
DETACH DELETE n
RETURN count(*);

If you want to remove everything like property keys, stop neo4j service and remove everything from data/graph.db

like image 103
Morteza Zabihi Avatar answered Sep 13 '25 07:09

Morteza Zabihi


Instead of use Cypher to delete all the graph you can I stop Neo4j and delete the data/graph.db folder. After it restart Neo4j.

Another suggestion is to run your deletion query with a limit repeating it until no more records exists.

For example:

Match (n) detach delete n limit 5000
like image 32
Bruno Peres Avatar answered Sep 13 '25 08:09

Bruno Peres