2016-03-29 70 views
2

我對過濾時密碼查詢的優化有疑問。 實體和地址節點之間存在關係。這裏有兩個查詢 -哪個更好的方法來過濾密碼查詢

match(a:Address)<-[r]-(e:Entity) where a.addressLocation=~".*(?i)ABC XYZ.*" return r 

match(e:Entity)-[r]->(a:Address) where a.addressLocation=~".*(?i)ABC XYZ.*" return r 

這些以上兩個查詢哪個更好?

回答

1

使用命令

profile match(a:Address)<-[r]-(e:Entity) where a.addressLocation=~".*(?i)ABC XYZ.*" return r 
profile match(e:Entity)-[r]->(a:Address) where a.addressLocation=~".*(?i)ABC XYZ.*" return r 

要看看是否有你的新版本任何區別在這兩個查詢。 此外,我建議,如果你知道有一個與creteria a.addressLocation=~".*(?i)ABC XYZ.*" 少數地址嘗試使用查詢像

match(a:Address) where a.addressLocation=~".*(?i)ABC XYZ.*" 
with a Match (a)<-[r]-(e:Entity) return r 

要了解更多關於這裏介紹一下http://neo4j.com/docs/stable/execution-plans.html

+0

謝謝,我會看看如果這可以幫助。 – RCS

1

噢! 哦,是啊! 哦,是啊!

+0

我使用第二個查詢我的Rest App中多個實體共享地址位置,並且我在Neo4j數據庫中有數百萬個實體和地址節點。有時它工作得很好,有時在我的Rest App中它給了我ReadTimeOut Exception。 – RCS

+0

這就是原因,我想如果我可以正確過濾我的查詢,我可以避免得到ReadTimeOut異常。有沒有其他的方式來獲取ReadTimeOut Exception請騎我知道。 – RCS

+0

我編輯了我的答案。看看是否有幫助 – hspandher

相關問題