Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top