簡體   English   中英

Neo4J查詢性能

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM