首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >neo4j优化读取查询性能

neo4j优化读取查询性能
EN

Stack Overflow用户
提问于 2022-09-27 08:51:14
回答 1查看 47关注 0票数 0

在优化读取查询时,我需要帮助,当活动用户在250左右运行时,它变得非常慢(大约3秒),并且负载较少,只需几毫秒。我们的图形大小为435 MB,我们正在一个16 GB内存的neo4j 3.5集群上运行它。

查询:

代码语言:javascript
复制
MATCH (lesson:Mlo)-[MLO_TO_CONTENT]->(Content)-[CONTENT_TO_SKILL]->(skill:Skill)<-[OUTCOME_TO_SKILL]-(outcome:Outcome)
WHERE lesson.mloUuid IN ["uuid-1", "uuid-2"]
AND outcome.boardId = lesson.boardId
AND outcome.gradeId = lesson.gradeId
AND outcome.subjectId = lesson.subjectId
AND exists(skill.name)
AND exists(skill.uuid)
AND exists(outcome.outcomeKey)
RETURN lesson.mloUuid as lessonUuid, skill.name as skillName, skill.uuid as skillUuid, collect(distinct outcome.outcomeKey) as outcomes

图:

代码语言:javascript
复制
Heap 6144 MB
Page Cache 5293 MB

*sysinfo

代码语言:javascript
复制
Page Cache
Faults    7348
Evictions    0
File Mappings    2544
Bytes Read    58851674
Flushes    9140
Eviction Exceptions    0
File Unmappings    2516
Bytes Written    280641246
Hit Ratio    100.00%
Usage Ratio    1.10%

配置文件:

EN

回答 1

Stack Overflow用户

发布于 2022-09-28 06:45:10

您可以尝试对此进行分析:

代码语言:javascript
复制
MATCH (lesson:Mlo)-[MLO_TO_CONTENT]->(content)-[CONTENT_TO_SKILL]->(skill)<-[OUTCOME_TO_SKILL]-(outcome)
WHERE lesson.mloUuid IN ["uuid-1", "uuid-2"]
AND skill.name IS NOT NULL
AND skill.uuid IS NOT NULL
AND outcome.outcomeKey IS NOT NULL
AND outcome.boardId = lesson.boardId
AND outcome.gradeId = lesson.gradeId
AND outcome.subjectId = lesson.subjectId
RETURN lesson.mloUuid as lessonUuid, skill.name as skillName, skill.uuid as skillUuid, collect(distinct outcome.outcomeKey) as outcomes

在这个查询中,我们删除了skilloutcome节点的标签匹配。在配置图中,他们的点击量约为5万次。但是,如果响应中存在某些不匹配,则应该重新添加它们。另外,我们已经用exists()更新了IS NOT NULL检查,以便使用更多的索引。您可以阅读更多关于它的这里

另一个可能的选择是在查询中提供JOIN提示。这些提示基本上告诉查询规划者如何针对某些特定节点遍历路径,从而将遍历成本降到最低。尝试下面的查询,我们已经使用子句USING JOIN ON提供了提示,任何节点都可以跟随子句,我使用了skill节点,但是您也可以使用lessoncontentoutcome,并比较查询响应时间。

代码语言:javascript
复制
PROFILE MATCH (lesson:Mlo)-[MLO_TO_CONTENT]->(content)-[CONTENT_TO_SKILL]->(skill:Skill)<-[OUTCOME_TO_SKILL]-(outcome:Outcome)
USING JOIN ON skill
WHERE lesson.mloUuid IN ["uuid-1", "uuid-2"]
AND outcome.boardId = lesson.boardId
AND outcome.gradeId = lesson.gradeId
AND outcome.subjectId = lesson.subjectId
AND skill.name IS NOT NULL
AND skill.uuid IS NOT NULL
AND outcome.outcomeKey IS NOT NULL
RETURN lesson.mloUuid as lessonUuid, skill.name as skillName, skill.uuid as skillUuid, collect(distinct outcome.outcomeKey) as outcomes

您可以阅读更多关于规划师提示这里的信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73864778

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档