Neo4j slow creation method [closed]

余生颓废 提交于 2019-12-06 02:38:15

Some ideas that may help:

  1. Execute the query:

    MATCH (d:Decision)<-[:VOTED_FOR]-(vg:VoteGroup)-[:VOTED_ON]->(c:Criterion) WHERE id(d) = {decisionId} AND id(c) = {criterionId} RETURN vg

from the web interface or the console and check how it behaves. Try for the same ids you use in the app. Check what is the execution time.

  1. Has VoteGroup numerous relations to Votes? If yes, can you remove:

    @RelatedTo(type = CONTAINS, direction = Direction.OUTGOING) private Set<Vote> votes = new HashSet<>();

and keep information about relation on the Vote side only? Can you check the performance after that change?

  1. Can you use some kind of a profiler tool to identify the exact place of performance problems? Right now it may be still difficult to guess...

  2. Does the code behave as it should? Don you have any duplicates in the DB? Maybe you have bugs in your hashCode/equals methods that cause much more changes in the DB than there really should be?

You could try to reformulate the getVoteGroupForDecisionOnCriterion query as follows, in order to avoid the cartesian product:

MATCH (d:Decision) WHERE id(d) = {decisionId}
WITH d MATCH (c:Criterion) WHERE id(c) = {criterionId}
WITH d,c MATCH d<-[:VOTED_FOR]-(vg:VoteGroup)-[:VOTED_ON]->c
RETURN vg

I'm moved to new Neo4j 2.2.4 and SDN 3.4.0.RC1 and the issue disappeared

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!