我正在使用Neo4j'neo4j-community-2.3.0-RC1'版本。 在我的数据库中只有1054个节点。 当我使用'allShotestPaths'函数进行路径查询时,为什么它很慢。 它需要大约1秒以上,以下是单元测试结果:Neo4j:为什么allShortestPaths函数的性能如此之慢?
√ search optimalPath Path (192ms)
√ search optimal Path by Lat Lng (1131ms)
我应该优化查询?
MATCH path=allShortestPaths((start:潍坊_STATION)-[rels*..50]->(end:潍坊_STATION {name:"火车站"}))
RETURN NODES(path) AS stations,relationships(path) AS path,length(path) AS stop_count,
length(FILTER(index IN RANGE(1, length(rels)-1) WHERE (rels[index]).bus <> (rels[index - 1]).bus)) AS transfer_count,
length(FILTER(rel IN rels WHERE type(rel)="WALK" )) AS walk_count
order by transfer_count,walk_count,stop_count
由纬度LNG查询最优路径:对 'optimalPath' 和 '最佳路径由纬度LNG'
optimalPath查询以下是querys
MATCH path=allShortestPaths((start:潍坊_STATION {name:"公交总公司"})-[rels*..50]->(end:潍坊_STATION {name:"火车站"}))
WHERE
round(
6378.137 *1000*2*
asin(sqrt(
sin((radians(start.lat)-radians(36.714))/2)^2+cos(radians(start.lat))*cos(radians(36.714))*
sin((radians(start.lng)-radians(119.1268))/2)^2
))
)/1000 < 0.5 // this formula is used to calculate the distance between two GEO coordinate (latitude\longitude)
RETURN NODES(path) AS stations,relationships(path) AS path,length(path) AS stop_count,
length(FILTER(index IN RANGE(1, length(rels)-1) WHERE (rels[index]).bus <> (rels[index - 1]).bus)) AS transfer_count,
length(FILTER(rel IN rels WHERE type(rel)="WALK" )) AS walk_count
order by transfer_count,walk_count,stop_count
,你可以在这里下载数据库:https://www.dropbox.com/s/zamkyh2aaw3voe6/data.rar?dl=0
我会很感激,如果有人能帮助我。感谢
您上传的数据库遗漏了大部分商店文件。 –
你见过沙滩鞋的功能吗? http://neo4j.com/docs/stable/query-functions-mathematical.html#functions-haversin –
传入的{lat}和{lon}参数是什么? –