I have an application that searches for items based on a postal code.
When searching for the postal code, I return all products that are from that City/Neighborhood (done by parsing the postal/zip codes).
I now need to sort these products based on distance from the original postal/zip code.
I have the Lat/Long stored on the DB and plan to use the Haversine formula to calculate an apprx distance from the original query.
My question is, where should this be calculated. Should I do this in a stored procedure, before returning my data set?
Or should I return my data set, with my Lat/Long, and calculate it server side before returning to user.
The calculation may need to be performed for up to 1000 results.