我正在使用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}參數是什麼? –