Is the "specific distance" somewhat constant? IE are you always looking for "all points within 1 mile" or is the radius changing?
What percentage of the total number of records do you expect to receive in any given query? ten%? 0.10%?
If you always have the same radius, build a grid of squares with the same length as the radius. Assign each list of adjacent squares. Each item will know in which square it is located, from which you can get a list of all neighboring squares. Then run the calculation only at the points of these squares. This is similar to other answers that have appeared, but will be faster, because linear calculations are approximated by an indexed search, and not calculated between each point.
Even with a variable radius, you can still use the above, but you will need to calculate how many "neighbors" you need to include. This is only possible if you expect to receive a small subset of the total from any single query.
source share