[英]Neo4J query performance
我有一个相对较小的图形(250万个节点,5M rel,770万个属性),并且正在执行(在我看来是这样)一个简单的查询,但是在基于SSD的快速笔记本电脑上执行需要63秒。 这真的是我应该从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;
更新:只想发布更新的查询:
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;
除非有特定的用例,否则通常应尝试删除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;
编辑:正如评论中所讨论的,我们可以通过强制ORDER BY
在聚合之后而不是聚合之前获得更好的性能。 我们可以通过使用WITH
来做到这一点(因此,我们只是在讨论特定的用例)。 此处的区别在于,我们已将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.