Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j删除标签中的所有节点及其关系_Neo4j_Cypher - Fatal编程技术网

Neo4j删除标签中的所有节点及其关系

Neo4j删除标签中的所有节点及其关系,neo4j,cypher,Neo4j,Cypher,我知道这个问题已经被问过很多次了,但是答案并没有解决我的问题。 我想删除标签电话号码中的所有节点及其关系(百万)。 我已尝试通过以下方式首先删除关系: MATCH (:Person)-[r:HAS_TELEPHONE_NUMBER]->(:TelephoneNumber) DELETE r 但是经过一定的时间后,我得到一个错误GC开销限制超过了。我尝试过这样限制查询: MATCH (:Person)-[r:HAS_TELEPHONE_NUMBER]->(:TelephoneNumb

我知道这个问题已经被问过很多次了,但是答案并没有解决我的问题。 我想删除标签电话号码中的所有节点及其关系(百万)。 我已尝试通过以下方式首先删除关系:

MATCH (:Person)-[r:HAS_TELEPHONE_NUMBER]->(:TelephoneNumber)
DELETE r
但是经过一定的时间后,我得到一个错误
GC开销限制超过了
。我尝试过这样限制查询:

MATCH (:Person)-[r:HAS_TELEPHONE_NUMBER]->(:TelephoneNumber)
WITH r LIMIT 100
DELETE r
但我也犯了同样的错误。 我试过另一种方法:

MATCH (t:TelephoneNumber) OPTIONAL MATCH (t)-[r]-()
DELETE t,r
但我又犯了同样的错误。
如何在不超过垃圾收集器开销限制的情况下删除标签中的所有节点及其关系?

您可能希望利用APOC过程。此外,由于您希望删除节点,因此“分离删除”将有所帮助,因为这将删除节点中的所有关系,然后删除节点本身

用法的一个例子可能是:

call apoc.periodic.commit("
match (tel:TelephoneNumber)
with tel limit {limit}
detach delete tel
return count(*)
",{limit:10000})

您可以根据需要调整批量大小限制,但10000通常有效。

作为一个快速更新,对于大多数周期性批处理的情况,
apoc.periodic.iterate()
几乎应该始终使用,因为它更易于使用且效率更高。