Load an object in Neo4j OGM 1.1.3 ogm depth of 2 very slow

柔情痞子 提交于 2019-12-08 21:57:28

问题


I get a timeout while querying for depth 2 using session.load().I'm working with Neo4j OGM 1.1.3 (Attempting to migrate from Spring Data Neo4j 3.4). Trying to load a Node object

class Node {
    Long id;
    String name;

    @Relationship(type="NodeToCategory")
    Category category;

    @Realtionship(type="NodeToChildNode")
    Node node
}

class Category {
    Long id;
    String name;
    String color;
    Date createdAt;
}

The category that is connected to my node is very popular (20,000 nodes have the same category) and when I use run session.load(Node.class, 1L, 2) the request times out. Can it be that it is trying to query for all relationships of the category (even though my model Category in Java ignores this relationship)?

what i would expect it to load is simply:

|My Node
|   |category
|   |child node
|   |   | category
|   |   | child node

Which is not a very heavy request and should not timeout (unless it is loading unneeded relationships.

Is there a way to tell a only load certain relationships to deeply?

For example i would like to load 10 levels of a tree but other information on my tree (such as category, role which are not really tree nodes but simply represent more information) I would only want to load them without their relationships. So I would like to load all Node objects and only load other objects along the way without their relationships.

UPDATE

found two open issues that seem to address these problems:

https://github.com/neo4j/neo4j-ogm/issues/55

https://github.com/neo4j/neo4j-ogm/issues/70


回答1:


This issue has been addressed in OGM 3.0 with schema based loading.

Schema based loading means that OGM now looks at your object domain model an only fetches what is really present in your model, instead of everything up to the specified depth.

In your case, as the Category don't link back to Node, the new version won't load these many unneeded nodes, leading to a huge performance improvement.



来源:https://stackoverflow.com/questions/33486334/load-an-object-in-neo4j-ogm-1-1-3-ogm-depth-of-2-very-slow

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