以下查詢無法在具有 ~2M 節點的資料集上運行。我該怎么做才能讓它運行得更快?
MATCH (cc:ConComp)-[r1:IN_CONCOMP]-(p1:Person)-[r2:SAME_CLUSTER]-(p2:Person)
WHERE cc.cluster_type = "household"
MERGE (cluster:Cluster {CLUSTER_TMP_ID:cc.CONCOMP_ID '|' r2.root_id, cluster_type:cc.cluster_type })
MERGE (cluster)-[r3:IN_CLUSTER]-(p1)
uj5u.com熱心網友回復:
一些建議:
- 為您的關系添加方向將減少 MATCH 中的路徑數量
- 確保您在合并的所有屬性上都有索引
- 在第二個 MERGE 中,還添加方向。
uj5u.com熱心網友回復:
我終于通過使用以下查詢(并通過索引 cc.cluster_type 和 cc.CONCOMP_ID)找到了解決方案:
CALL apoc.periodic.iterate('MATCH (cc:ConComp)<-[r1:IN_CONCOMP]-(p1:Person)-[r2:SAME_CLUSTER]-(p2:Person) WHERE cc.cluster_type = "household" WITH DISTINCT cc.CONCOMP_ID "|" r2.root_id as id_name, cc.cluster_type as cluster_type_name, p1 RETURN id_name, cluster_type_name, p1', '
MERGE (cluster:Cluster {CLUSTER_TMP_ID: id_name, cluster_type: cluster_type_name})
MERGE (cluster)-[r3:IN_CLUSTER]->(p1)', {batchSize:10000, parallel:false})
我確切地說我之前用apoc.periodic.iterate運行了我的初始問題查詢,但沒有成功。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/389805.html
