首页 > 解决方案 > NEO4J Cypher 查询速度慢

问题描述

我已经努力优化以下查询,但无法将其缩短到两分钟以下 - 这是预期的吗?有什么办法可以加快速度。我已添加索引并WITH尽可能使用。

match (md:MarketingDetail {Status: 'Live'})
with md limit 10
match (md) -[:Has_Area]-> (a:Area)
with md, a
match (ss:SavedSearch) -[:Has_Area]->(a)
with md, ss match
(md) -[:Has_Trade] -> (st:SectorTrade) <-[:Has_Trade]- (ss)
where ((md.FreeholdTenure ='Freehold'
and ss.FreeholdTenure = 'true'
and (md.FreeholdSearchPrice >= ss.PriceFrom
or md.FreeholdSearchPrice is null)
and (md.FreeholdSearchPrice <= ss.PriceTo
or md.FreeholdSearchPrice is null))
or (md.LeaseholdTenure is not null
and ss.LeaseholdTenure = 'true'
and (md.LeaseholdSearchPrice >= ss.PriceFrom
or md.LeaseholdSearchPrice is null)
and (md.LeaseholdSearchPrice <= ss.PriceTo
or md.LeaseholdSearchPrice is null)))
return count(ss)

这是上述查询的配置文件 -

查询配置文件

谢谢!

标签: neo4jcypher

解决方案


根据您的说法PROFILE,您没有 的索引:MarketingDetail(Status),这对于您的查询非常重要,因为第一个MATCH.

此外,重组您的查询(可能以@DonWeldon 建议的方式)应该会有所帮助。


推荐阅读