Neo4j广度优先搜索速度太慢 [英] Neo4j breadth first search is too much slow
问题描述
我需要在我的数据库中首次搜索宽度。有3.863个节点,2.830.471个属性和1.355.783个关系。 N是我的起点,m是我在查询中的终点,但它太慢了,所以在开始查询时,我无法得到结果,它位于以下段中:
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
我如何优化该查询?因为它必须在20秒内完成最大。我在我自己的电脑上安装了8GB的ram,但是我为此购买了24GB的ram专用服务器。另外,我的堆大小是4096-5120 MB。还有我的其他配置是关于查询在以下段:
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?
推荐答案
您的查询基本上收集所有路径的任意长度,对它们进行排序并返回最短路径。有一种方法可以做到这一点:
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.
这篇关于Neo4j广度优先搜索速度太慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!