简体   繁体   English

Neo4J查询性能

[英]Neo4J query performance

I have a relatively small graph (2.5M nodes, 5M rel, 7.7M properties) and I am executing (what seems to me) a simple query but it's taking 63 seconds to execute on a fast SSD-based laptop. 我有一个相对较小的图形(250万个节点,5M rel,770万个属性),并且正在执行(在我看来是这样)一个简单的查询,但是在基于SSD的快速笔记本电脑上执行需要63秒。 Is this really the performance I should expect from Neo4j, or is there anything wrong with the query? 这真的是我应该从Neo4j期待的性能,还是查询有什么问题?

start ph=node(2)
match ph-[:NEXT_LEVEL]->c
where c.tag = "class 1"
with c
match c-[:NEXT_LEVEL]->p<-[:SOLD]-l<-[:LINE]-h-[:SOLD_IN]->s
return s.tag as store, sum(l.item_quantity) as quantity order by s.tag;

控制台输出

Update: Just wanted to post the updated query: 更新:只想发布更新的查询:

start ph=node(2)
match ph-[:NEXT_LEVEL]->c-[:NEXT_LEVEL]->p<-[:SOLD]-l<-[:LINE]-h-[:SOLD_IN]->s
where c.tag = "class 1"
with s.tag as store, sum(l.item_quantity) as quantity
return store, quantity order by store;

具有更新查询的控制台

Unless you have a specific use case, you should usually try removing the WITH clause to boost performance. 除非有特定的用例,否则通常应尝试删除WITH子句以提高性能。

start ph=node(2)
match ph-[:NEXT_LEVEL]->c-[:NEXT_LEVEL]->p<-[:SOLD]-l<-[:LINE]-h-[:SOLD_IN]->s
where c.tag = "class 1"
return s.tag as store, sum(l.item_quantity) as quantity order by s.tag;

Edit: As discussed in the comments, we can get even better performance by forcing the ORDER BY to happen after aggregation instead of before. 编辑:正如评论中所讨论的,我们可以通过强制ORDER BY在聚合之后而不是聚合之前获得更好的性能。 We can do this by using WITH (so there's that specific use case we were just talking about). 我们可以通过使用WITH来做到这一点(因此,我们只是在讨论特定的用例)。 The difference here is that we've moved the WITH clause as far to the end as possible, allowing all previous processing to be grouped together rather than separated. 此处的区别在于,我们已将WITH子句尽可能移到末尾,从而允许将所有以前的处理分组在一起而不是分开。

start ph=node(2)
match ph-[:NEXT_LEVEL]->c-[:NEXT_LEVEL]->p<-[:SOLD]-l<-[:LINE]-h-[:SOLD_IN]->s
where c.tag = "class 1"
with s.tag as store, sum(l.item_quantity) as quantity
return store, quantity order by store;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM