问题描述
我已经构建了一个Java应用程序,该应用程序在REST模式下使用Spring和Neo4J.Neo4j已安装在Linux Red Hat计算机上,并且我没有更改其默认配置.
I've built a Java application that uses Spring and Neo4J in REST mode.The Neo4j is installed on Linux Red Hat machine and I changed nothing in its default configuration.
当我使用Java服务查询数据时,查询/插入的运行速度非常慢,但是当我通过远程Web管理员执行相同的操作时,相同的查询运行速度很快.
Queries / inserts run VERY slow when I use my Java Services to query data, but the same queries run fast when I do the same operations through the remote web admin.
例如,当我从Web管理员运行该查询时,它会在几毫秒内运行,但是从我的Rest服务调用该查询需要30秒钟(!!)以上的时间才能返回.目前,我的数据库上还没有很多数据(至今)-数千个节点.
for example, I have a query that runs in few milliseconds when I run it from the web admin, but it takes more than 30 seconds (!!) to return when calling it from my Rest service. Currently, I don't have a lot data on my DB (yet) - few thousands of nodes.
我不知道问题可能出在哪里-我想如果它直接运行很快,从我的服务运行时也应该很快,不是吗?
I don't have a clue where the problem might be - I guess that if directly it runs fast, it should be fast too when running from my service, isn't it?
这是一个示例查询(我将其缩进以方便阅读):
This is an example query (I indented it for easy read):
@Query("start movie=node({0})
match (topic)<-[r:relatesToTopic]-(movie)
where r.orderInTop5? is not null and r.orderInTop5?>0
return topic order by r.orderInTop5 asc;")
public Iterable<Topic> findTopTopics(Content content);
直接在网络管理员中,看起来像这样:
Directly in the web admin, it looks like this:
start movie=node(50537)
match (topic)<-[r:relatesToTopic]-(movie)
where r.orderInTop5? is not null and r.orderInTop5?>0
return topic.name , topic.category, r.orderInTop5
order by r.orderInTop5 asc;
如果有关系,则在抽象父类而不是Movie类本身上声明relatedToTopic关系.
If it matters, the relatesToTopic relationship is declared on an abstract parent class and not on the Movie class itself.
我认为我有一个普遍的问题,因为它对任何查询或创建都很慢.不使用Neo4J的服务运行速度非常快.
I think I have a general problem because it is slow for any query or create. Services that doesn't use the Neo4J run very fast.
可以是REST配置吗?还有其他东西吗?
Can it be the REST configuration? something else?
对于在哪里寻找或测试什么的任何想法,我深表感谢.
I appreciate any ideas where to look for or what to test.
谢谢卡梅尔
推荐答案
卡梅尔(Carmel)
Carmel,
基于REST的SDN尚未提供高性能访问.
SDN over REST is not yet providing high-performance access.
您可能会尝试使用带cypher注释的存储库方法,并且仅返回纯数据,因此不要返回"topic",而是返回所需的topic属性,然后使用@MapResult
或@QueryResult
映射来访问您的返回值值.
You might try to use repository methods annotated with cypher and returning only plain data, so don't return "topic" but the topic properties that you need and then use a @MapResult
or @QueryResult
mapping to access your return values.
请参阅: http://docs.spring.io/spring-data/data-neo4j/docs/2.3.x/reference/htmlsingle/#d0e964
这篇关于Neo4J REST性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!