[英]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.