我有两个表,即
1)地点数据-240万条记录
2)办公室数据-4万条记录
我有一个Neo4J查询,它通过用户界面从用户那里获取3个输入,并在运行时使用纬度/经度信息计算用户之间的距离后输出结果。我只想在运行时计算距离
以下是查询:-
MATCH (c:places), (c2:office)
WHERE c2.office_id = {office}
AND c2.city = {city}
AND c.category = {category}
RETURN c.places_id as place_name, c.category as Category,
c.sub_category as Sub_Category, distance(c.location, c2.location)
as Distance_in_meters order by distance(c.location, c2.location) LIMIT 50
上面的查询花费了大约10-15秒在UI上输出结果,这有点烦人。您能帮忙优化性能吗?
答案 0 :(得分:0)
您可以尝试下一个查询:
MATCH (c:places), (c2:office {office_id: YourOffice, city: YourCity, category: YourCategory}) RETURN c.places_id as place_name, c.category as Category,
c.sub_category as Sub_Category, distance(c.location, c2.location)
as Distance_in_meters ORDER BY Distance_in_meters ASC/DESC LIMIT 50
并决定如何排序结果:ASC或DESC