I have tried hard to optimize the following query but can't get it down to under two minutes - is this expected? Is there any way I can speed things up. I have added indexes and used WITH
wherever possible.
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)
Here is the profile of the above query -
Thanks!