大批量子图数据删除

 

Here’s the table of contents:

  1. CALL apoc.periodic.iterate刪除数据 【占满整个堆内存,造成垃圾回收暂停。】
  2. CALL apoc.periodic.commit刪除数据[remove和delete标签和属性的时候使用下列过程][图数据库分配到的内存太小时使用这种方式删除数据]

CALL apoc.periodic.iterate刪除数据 【占满整个堆内存,造成垃圾回收暂停。】

1、CALL apoc.periodic.iterate('MATCH (f:HORGShareHold) WHERE f.hcode=~\'-HORG.*[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\' AND size((f)--())=0 RETURN f','WITH {f} AS f DELETE f', {parallel:true,batchSize:10}) YIELD  batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations RETURN batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations;
2、CALL apoc.periodic.iterate('OPTIONAL MATCH p=(f:HORGShareHold)-[r]-(k:HORGShareHold) WHERE f.hcode=~\'-HORG.*[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\' RETURN f,r','WITH {f} AS f,{r} AS r DELETE f,r', {parallel:true,batchSize:10000}) YIELD  batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations RETURN batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations;
3、CALL apoc.periodic.iterate('MATCH (f:HORGShareHold)-[r]-() WHERE f.name=\'null\' RETURN f,r','WITH {f} AS f,{r} AS r DELETE f,r', {parallel:false,batchSize:1000}) YIELD  batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations RETURN batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations;
4、CALL apoc.periodic.iterate('MATCH p=(f:HORGShareHold)-[r]->(k:HORGShareHold) RETURN r','WITH {r} AS r REMOVE r.shareholding_detail', {parallel:false,batchSize:1000}) YIELD  batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations RETURN batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations;
5、CALL apoc.periodic.iterate('MATCH (n:PREClusterHeart公司) RETURN n','WITH {n} AS n REMOVE n:PREClusterHeart公司', {parallel:false,batchSize:1000}) YIELD  batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations RETURN batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations;
6、CALL apoc.periodic.iterate('MATCH (n:PRE公司中文名称) RETURN n','WITH {n} AS n REMOVE n.cluster_id', {parallel:false,batchSize:1000}) YIELD  batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations RETURN batches,total,timeTaken,committedOperations,failedOperations,failedBatches,retries,errorMessages,batch,operations;

CALL apoc.periodic.commit刪除数据[remove和delete标签和属性的时候使用下列过程][图数据库分配到的内存太小时使用这种方式删除数据]

1、CALL apoc.periodic.commit('MATCH (f:HORGShareHold) WHERE f.hcode=~\'-HORG.*[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\' AND size((f)--())=0 WITH f LIMIT $limit DELETE f RETURN count(*)',{limit: 10000})
2、CALL apoc.periodic.commit('OPTIONAL MATCH p=(f:HORGShareHold)-[r]-(k:HORGShareHold) WHERE f.hcode=~\'-HORG.*[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\' WITH f,r LIMIT $limit DELETE f,r RETURN count(*)',{limit: 10000})
3CALL apoc.periodic.commit('MATCH (n:PREClusterHeart公司) WITH n LIMIT $limit REMOVE n:PREClusterHeart公司 RETURN count(*)',{limit: 1000})
4、CALL apoc.periodic.commit('MATCH (n:PRE公司中文名称) WHERE EXISTS(n.cluster_id) WITH n LIMIT $limit REMOVE n.cluster_id RETURN count(*)',{limit: 1000})

参考链接