在设法使用空间插件完成所有工作后,我正在优化我的查询以充分利用它
一开始查询耗时10秒
找到这个问题后 Improve Neo4j Cypher Performance On Lengthy Match 我得到的查询在3秒内运行但仍然有140k dbHits
我尝试将查询分解为更多匹配,之后我将其提升到50k dbHits,但奇怪的是执行时间实际上增加了
如果dbHits与执行时间之间存在直接关系,有人可以解释一下吗?
以下是我的查询示例(它是查询的简短版本,真正的查询要大得多)
START user=node(1), friend=node:userPosition("withinDistance:[0.003000,0.003000,10.000000]")
WHERE friend.birthYear >= 1952 AND friend.birthYear <= 1977
WITH DISTINCT friend, user
MATCH (user)-[:SPEAKS]->(:Language)<-[:SPEAKS]-(friend)
WITH friend, user
MATCH (user)-[:EXPECTS]->(expectedObligatoryAnswers:Answer {isOptional : 0}))<-[:ANSWERED]-(friend)
WITH friend, user,COUNT(DISTINCT expectedObligatoryAnswers.questionId) AS countExpectedObligatoryAnswers
WHERE (countExpectedObligatoryAnswers = 2)
RETURN friend
LIMIT 3;
在更大的查询中,这得到3秒的执行时间,但140k的dbHits
打破前两场比赛后
MATCH (user)-[:SPEAKS]->(lang:Language)
WITH user, friend, lang
MATCH (lang)<-[:SPEAKS]-(friend)
WITH friend, user
MATCH (user)-[:EXPECTS]->(expectedObligatoryAnswers:Answer {isOptional : 0}))
WITH friend, user, expectedObligatoryAnswers
MATCH (expectedObligatoryAnswers)<-[:ANSWERED]-(friend)
这相当于dbHits(50k)的1/3,但执行时间增加了2秒
是否有正在进行的cypher分析文档?
由于