4

I'm trying to delete 1 million nodes in cyphper at one query using web admin(i.e localhost:7474/browser).
These nodes is labeled as User. I ran following query, then returned Unknown error after waiting about 1minutes.

match (u:User) delete u

This query returned Unknown error every time. and I confirm my PC resources didn't lack. I'm using Neo4j version 2.0.0 RC1 community edition. and Neo4j Hosted on local.
Is My trying way for deletion nodes wrong?
Thanks

ekkis
  • 9,804
  • 13
  • 55
  • 105
Michael
  • 143
  • 4
  • 13

3 Answers3

6

You should do write operations with a reasonable transaction size of ~10-50k atomic operations. Therefore you can use limit and run the statement until all users are gone:

match (u:User) with u limit 1000 delete u
istruble
  • 13,363
  • 2
  • 47
  • 52
Stefan Armbruster
  • 39,465
  • 6
  • 87
  • 97
  • 1
    Thank you for the advice. I tried to delete above query, but it returned an Unknown error. I executed an following query instead. `match (u:User) with u limit 1000 delete u` It works fine:) Thanx – Michael Dec 10 '13 at 09:21
4

With Neo4j 3.x and forward you can run large delete transactions using APOC too:

call apoc.periodic.iterate("MATCH (u:User) return u", "DETACH DELETE u", {batchSize:1000})
yield batches, total return batches, total
ThirstForKnowledge
  • 1,245
  • 1
  • 10
  • 27
-2

I've found that just removing the neo4j/data folder is the fastest way to delete the db.

eighteyes
  • 1,306
  • 1
  • 11
  • 18