Spring Data Neo4j:为什么保存方法需要这么长时间? [英] Spring Data Neo4j: why save method takes so long?

查看:69
本文介绍了Spring Data Neo4j:为什么保存方法需要这么长时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用Spring Data Neo4j,我发现保存节点实体类(> 300ms/node)时花了太多时间,这实际上很简单(它们只包含一个属性,一个简单长ID).节点之间的关系也非常简单(我只是试图表示一个社交网络).对于其余部分,我使用密码查询,并且时间要快得多并且可以接受(约3-30毫秒).

I'm using Spring Data Neo4j in my project and I've noticed it takes too much time while saving my node entity classes (>300ms/node), which actually are pretty simple (they only contain one property, a simple long id). The relationships between nodes are also quite simple (I'm simply trying to represent a social network). For the rest, I use cypher queries and the timings are pretty much faster and acceptable (~3-30ms).

事实证明这是一个巨大的问题,因为我项目的基本部分是填充图形,然后才进行触发"查询.有什么建议是什么原因?我正在使用的Spring Data Neo4j版本是2.1.0.RELEASE,我正在使用存储库方法.

This turns out to be a huge problem, since a basic part of my project is populating the graph and only then "trigger" queries. Any suggestions what the reason(s) could be? The Spring Data Neo4j version I'm using is 2.1.0.RELEASE and I'm using the repositories approach.

提前谢谢!

推荐答案

这取决于您使用的映射模式,简单的映射要慢得多,因为它必须将对象图合并回Neo4j.高级映射要快得多,因为它是Neo4j之上的薄层(读取和写入).

It depends on the mapping mode you use, simple mapping is much slower as it has to merge your object graph back to Neo4j. Advanced mapping is much faster as it is a thin layer on top of Neo4j (read and write through).

无论如何,您都应该在跨业务操作的更高级别上创建事务.

You should create the transaction on a higher level anyway that spans a business operation.

这篇关于Spring Data Neo4j:为什么保存方法需要这么长时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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