在Neo4j OGM 1.1.3 ogm深度为2的对象中加载对象非常慢 [英] Load an object in Neo4j OGM 1.1.3 ogm depth of 2 very slow

查看:112
本文介绍了在Neo4j OGM 1.1.3 ogm深度为2的对象中加载对象非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用session.load()查询深度2时出现超时.我正在使用Neo4j OGM 1.1.3(尝试从Spring Data Neo4j 3.4进行迁移).尝试加载Node对象

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;
}

连接到我的节点的类别非常受欢迎(20,000个节点具有相同的类别),当我使用run session.load(Node.class, 1L, 2)时,请求超时.可能是因为它正在尝试查询类别的所有关系(即使我在Java中的模型Category忽略了这种关系)?

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?

例如,我想加载一棵树的10个级别,但是我树上的其他信息(例如类别,角色并不是真正的树节点,只是代表更多信息),我只想加载它们之间没有关系的文件.因此,我想加载所有Node对象,并且一路上只加载其他对象而没有它们之间的关系.

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.

更新

发现了两个似乎可以解决这些问题的未解决问题:

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

推荐答案

此问题已在OGM 3.0中基于模式的加载得到解决.

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

基于架构的加载意味着OGM现在可以查看您的对象域模型,而仅获取模型中实际存在的内容,而不是获取指定深度的所有内容.

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.

在您的情况下,由于Category不会链接回Node,因此新版本不会加载这些许多不需要的节点,从而极大地提高了性能.

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.

这篇关于在Neo4j OGM 1.1.3 ogm深度为2的对象中加载对象非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆