Deleting all nodes and relationships in neo4j using cypher exceeds heap space

后端 未结 6 1630
失恋的感觉
失恋的感觉 2021-02-05 20:50

I have been trying to run this query as recommended in the neo4j google group and in other sources online:

START n = node(*) MATCH n-[r?]-() WHERE ID(n)>0 DELETE n, r;

6条回答
  •  广开言路
    2021-02-05 21:00

    I found a better solution in the Neo4J knowledge base [1]:

    CALL apoc.periodic.iterate(
        "MATCH (n) RETURN n",
        "DETACH DELETE n",
        {batchSize:1000}
    )
    YIELD batches, total RETURN batches, total
    

    [1] - https://neo4j.com/developer/kb/large-delete-transaction-best-practices-in-neo4j/

提交回复
热议问题