cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

What's the correct way to remove old db and start a fresh one?

Rogie
Node Link

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?

12 REPLIES 12

Hello @Rogie

With apoc:

CALL apoc.periodic.iterate('MATCH (n) RETURN n', 'DETACH DELETE n', {batchSize:1000, iterateList:true})

Regards,
Cobra

Trying this now, but it seems extremely slow. Has been running for an hour and still not complete.

How many nodes and relationships do you have?

Did you put index on them?

Around 10 million nodes. Each type has a uniqueness constraint for some attribute.

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.

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

How long should I expect it to take? There are 8GiB of ram on the system.

To be honest I don't know, 8Go looks small for a database with 10 millions nodes

You just need to wait

How much RAM do you suggest to have in this case?

I know there is hardware sizing but I never test it

stugorf
Node Clone

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> .

emigre459
Node Clone

To be clear, this solution only works for Enterprise Edition.