• We do this all the times for finding the nearest store from your current location. Yes, the big long formula works, is accurate down to inches, and is feasible on smaller data. When you start tracking thousands of data points it will slow down a bit.

    we pre-filter the data before sending it through a calculation to get the approximate distance using simple geometry.

    1 ) Calculate the lat/long delta for a reasonable search area.

    no sense searching a location on the east coast from a location on the west coast

    2) use that as a the first level of filter

    where dest.lat within current.lat +/- delta

    and dest.long within current.long +/- delta

    3) order by the full calculation to get the exact result

    If you have an index on lat, long SQL will just be comparing numbers without any calculations until the latter steps.

    I used this approach on a job search board and the customer could not break it.