Neo4j breadth first search is too much slow

我的未来我决定 提交于 2019-12-13 04:41:10

问题


I need breadth first search in my database. There are 3.863 nodes, 2.830.471 properties and 1.355.783 relationships. N is my start point and m is my end point in the query but It's too much slow, so I can't get result while I started the query that is in the following segment:

start n=node(42),m=node(31)
match p=n-[*1..]->m
return p,length(p)
order by length(p) asc
limit 1

How can I optimize that query? Because It must finish maximum in 20 seconds. I have 8gb ram in my own computer but I bought 24 Gb ram dedicated server for that. Also, My heap size is 4096-5120 MB. Also there is my other configs which is about query in the following segment:

neostore.nodestore.db.mapped_memory=2024M
neostore.relationshipstore.db.mapped_memory=614M
neostore.propertystore.db.mapped_memory=128M
neostore.propertystore.db.strings.mapped_memory=2024M
neostore.propertystore.db.arrays.mapped_memory=614M

How can solve this problem?


回答1:


Your query basically collects all paths at any lengths, sorts them and returns the shortest one. There is a way much better way to do this:

start n=node(42),m=node(31)
match p=shortestPath(n-[*..1000]->m)
return p,length(p)

It's a best practice to always supply a upper limit on variable depth patterns.



来源:https://stackoverflow.com/questions/23399824/neo4j-breadth-first-search-is-too-much-slow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!