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.

DELETE all data from AuraDB

gryfit
Node Link

I was trying to delete all data from the database. And I keep having issues. 

First, I was told just to stop the server and delete "/data" but it's not possible on AuraDB, and generally it's the wrong solution for the script I'm writing. 

Second, it was suggested to use 

"CREATE OR REPLACE DATABASE neo4j;"

But it's not supported on AuraDB

Now Third is the approach using Cypher, I found this query:

MATCH (n)-[r]-()
CALL { WITH r
DELETE r
} IN TRANSACTIONS OF 10000 ROWS
WITH n
CALL { WITH n
DELETE n
} IN TRANSACTIONS OF 10000 ROWS;

And I thought It was working until I got an OutOfMemory error. 

dbms.memory.transaction.global_max_size threshold reached

From running "profile" on this query, it turns out that the number of rows in the transaction has no impact on memory usage because the first fetch is eager.  To be clear increasing memory is not an option.

I'm completely out of ideas. Any help is greatly appreciated.

4 REPLIES 4

andy_hegedus
Graph Fellow

Hi,

Have you tried the more basic deletion method

Match (n) detach delete n

I think the detach statement is important because it removes the relationships to each node.

Andy

On the Aura console - click the overflow menu (the elipsis). There is a menu item that says "reset to blank"

Thanks for the suggestion, But unless it's possible via some API call, It's not gonna work for my script.
I need to be able to do this programmatically like "drop database" + "create database" in Postgres.

If you think its an overflow issue, maybe delete the information in two phases:

First:

match ()-[n]-()
CALL { 
    WITH n
    DELETE n
} IN TRANSACTIONS OF 10000 ROWS

 Second:

match (n)
CALL { 
    WITH n
    DELETE n
} IN TRANSACTIONS OF 10000 ROWS​