I'm building out a dating app that has a two-way distance restriction. I'm also adding in the capability to limit people to your country/state, ignoring the distance.
I've written the query, and tbh, the performance is horrible. I know what the problem is, I currently have to do 3 different scans of of the database looking for profiles that have specific distance/country/state properties. I know that the engine has to read the properties of the profile for each of the 3 sub queries that I'm doing in order to capture all possible matches. I also know that I need to change my model.
I currently have a Person node with (among others) properties for distance, country, state, city, zipCode and location. Location is a Point object. For the distance property, it can be either 10,30,50,100,250,500,999,1000,1001. The first 6 entries are mi/km options, 999 is Anywhere, 1000 is State only and 1001 is Country only.
Some use cases to make it more understandable are these:
Submitter requests 999 (Anywhere) They should see everyone that has anywhere as their entry, as well as those that the distance between the two are within the other person's distance setting.
Submitter requests 1000 (Only my State). They should only see people that are within their state, but not those that the other person's limits would prevent them. Such as they are 100 miles apart and the other person has a 10 mile limit.
So, my question is which way would provide the greatest performance for a query?
A) Create a single node for each of the distance items and then a relationship from every Person object to the matching distance node.
B) Create a Distance node for each Profile and connect it to the Person Node
C) Add a label to each Person node that designates the distance
D) Something else?????