I am making a dating site with a search function to find matches. One of the criteria is the distance between you and the possible match. How should I calculate the distance? I think calculating the exact distance for all possible matches might be too resource-intensive.I want a different solution so the nearby people are shown without being resource-intensive.
I had this idea:
When someone registers, save their coordinates rounded to (for the latitude) the nearest 5 minutes (=9 km) in the database? When searching for a match, search trough the database looking for the same coordinates as the user. After the matches are found, the exact distance could still be calculated.
How would that work for the longitude? Are there any better ways of doing this? I am not looking for the formula for calculating the distance. How can I find nearby matches without having to calculate the distance to every single possible match (thousands)?