Rogie
(Rogie)
June 13, 2020, 2:09pm
1
I don't know what the correct way to start an empty db. I know that I can remove all nodes and relations by doing
match (n)
with n limit 10000
DETACH DELETE n;
over and over again until everything is gone, but this is not reasonable to do on a huge database.
Is there not a simpler way to remove everything?
cobra
(Cobra)
June 13, 2020, 2:14pm
2
Hello @Rogie
With apoc:
CALL apoc.periodic.iterate('MATCH (n) RETURN n', 'DETACH DELETE n', {batchSize:1000, iterateList:true})
Regards,
Cobra
Rogie
(Rogie)
June 13, 2020, 3:14pm
3
Trying this now, but it seems extremely slow. Has been running for an hour and still not complete.
cobra
(Cobra)
June 13, 2020, 3:18pm
4
How many nodes and relationships do you have?
Did you put index on them?
Rogie
(Rogie)
June 13, 2020, 3:24pm
5
Around 10 million nodes. Each type has a uniqueness constraint for some attribute.
cobra
(Cobra)
June 13, 2020, 3:28pm
6
Do you have enough RAM and a good processor?
The request I gave you is the fastest one to delete everything in the database
Regards,
Cobra
Rogie
(Rogie)
June 13, 2020, 3:29pm
7
How long should I expect it to take? There are 8GiB of ram on the system.
cobra
(Cobra)
June 13, 2020, 3:44pm
8
To be honest I don't know, 8Go looks small for a database with 10 millions nodes
You just need to wait
Rogie
(Rogie)
June 13, 2020, 3:59pm
9
How much RAM do you suggest to have in this case?
cobra
(Cobra)
June 13, 2020, 4:06pm
10
I know there is hardware sizing but I never test it
stugorf
(Stugorf)
June 24, 2020, 5:53pm
11
Hi @Rogie ,
If you are using Neo4j 4.x you can switch to the system database using :use system
and then run drop database <database_name>
Then to create a new empty database run create database <database_name>
.
2 Likes
ofer.bar
(Ofer Bar)
June 25, 2020, 12:34pm
12
Why not simply create a new database?
Anyway, if you insist on deleting the objects don't forget to erase the indexes and constraints (schema). Just look up the command I don't remember the syntax.
emigre459
(Emigre459)
April 15, 2021, 12:14am
13
To be clear, this solution only works for Enterprise Edition.