简体   繁体   English

Neo4j 3.5 查询性能问题

[英]Neo4j 3.5 Query Performance Issue

I have following query running in neo4j (community 3.5)我在 neo4j(社区 3.5)中运行以下查询

MATCH (a:master_node:PERF:Application)-[r1]->(n:master_node:PERF)-[r:AFFINITY]->(m:master_node:PERF)<-[r2]-(a1:master_node:PERF:Application)
WHERE exists(n.latest_ingestion)
  AND exists(m.latest_ingestion)
  AND id(a) <> id(a1)
MERGE (a)<-[:APP_AFFINITY]-(a1)

and my configurations for neo4j are as follows:我对 neo4j 的配置如下:

heap_size : 8GB
page_cache : 4GB

and I have Indexes for the label(Application) on property(name) and above query running over 100k nodes.But the Query is running for longer time and consuming so much of memory.并且我在属性(名称)和以上查询上运行超过 100k 个节点的标签(应用程序)的索引。但是查询运行时间更长并且消耗了大量 memory。

Please help me out to improve the performance.请帮助我提高性能。

You're not using the name property in this query, so your index won't help.您没有在此查询中使用name属性,因此您的索引将无济于事。 The only indexes that may help would be on :master_node(latest_ingestion) or :PERF(latest_ingestion) , that may change the query from using label scans to index scans, depending on db statistics.可能有帮助的唯一索引是:master_node(latest_ingestion):PERF(latest_ingestion) ,这可能会将查询从使用 label 扫描更改为索引扫描,具体取决于数据库统计信息。

Also, you may want to consider batching these updates, likely using apoc.periodic.iterate() from APOC procedures.此外,您可能需要考虑批量处理这些更新,可能使用 APOC 过程中的apoc.periodic.iterate() Something like:就像是:

CALL apoc.periodic.iterate("
  MATCH (a:master_node:PERF:Application)-->(n:master_node:PERF)-[:AFFINITY]->(m:master_node:PERF)<--(a1:master_node:PERF:Application)
  WHERE exists(n.latest_ingestion)
    AND exists(m.latest_ingestion)
    AND id(a) <> id(a1)
  RETURN a, a1",
  "MERGE (a)<-[:APP_AFFINITY]-(a1)", 
  {}) YIELD batches, total, errorMessages
RETURN batches, total, errorMessages

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM