如何在 Neo4J 查询下方进行优化



我有两个表,即
1( 地点数据 - 240 万条记录 2( 办公数据 - 4万条记录

我有一个 Neo4J 查询,它通过 UI 从用户那里获取 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 上输出结果,这有点烦人。你能帮忙优化性能吗?

您可以尝试下一个查询:

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

最新更新