2014-07-14 28 views
1

我圖的問題是: 「哪位球員最常播放互相反對」查詢性能 - 四大關係

我查詢以下暗號:

match (p:Player)-[:PLAYS_IN]->(t:Team)-[:PLAYED]->(g:Game)<-[:PLAYED]-(tt:Team)<-[:PLAYS_IN]-(pp:Player) 
USING SCAN p:Player USING SCAN pp:Player 
return p.Lastname, pp.Lastname, count(pp) order by count(pp) desc limit 100; 

球員:158310 遊戲:215068 戰隊:218960

堆是6G,CPU是4核。

該查詢確實需要幾小時才能完成。 我應該如何優化它?

感謝, 邁克爾

+0

請在谷歌羣組上查看答案... –

回答

1

我想你可以通過簡化首次發現的問題哪支球隊發揮mosted對方,並基於該發現的球員。我不確定這個假設是否過分地解決了這個問題。

match (t:Team)-[:PLAYED]->(g:Game)<-[:PLAYED]-(tt:Team) 
with t, tt order by count(g) desc limit 1 
match (p:Player)-[:PLAYS_IN]->(t:Team)-[:PLAYED]->(g:Game)<-[:PLAYED]-(tt:Team)<-[:PLAYS_IN]-(pp:Player) 
return p.Lastname, pp.Lastname, count(pp) order by count(pp) desc limit 100; 
+1

感謝您的回答。但我認爲可能我進入了笛卡爾積問題: neo4j-sh(?)$ match(g:Game)return count(g); + ---------- + |計數(g)| + ---------- + | 215067 | + ---------- + 1 row 450 ms neo4j-sh(?)$ match(t:Team) - [:PLAYED] - >(g:Game)< - [:PLAYED ] - (tt:團隊)使用掃描g:遊戲返回計數(g); + ---------- + |計數(g)| + ---------- + | 4628408 | + ---------- + 1 row 35260 ms neo4j-sh(?)$ –