如何删除大量节点

How to delete lots of nodes

我想删除给定类型的所有节点及其关系。总共有 140 万个此类节点。

使用 MATCH (n:Type) DETACH DELETE n Neo4j 会在几分钟后自行挂起,必须重新启动。

有没有更好的删除大量节点的方法?我可以以某种方式成块删除它们吗(DELETE 不支持 LIMIT)?

试试这个

Match (n:Type) with n
Match (n)-[r]-()
Delete n, r

如果您想分块删除它们,查询将如下所示

Match (n:Type) with n limit 1000
Match (n)-[r]-()
Delete n, r