You could maybe improve performance like this:
Retrieve locations from your database where compared to your user’s location longitude difference < x and latitude difference < y to get results that are within an imaginary box of < ~12 miles around your user’s location on the map. The x value per mile depends on your latitude, but you should be able to use a hard value that covers the USA locations.
Then you could loop through the results and use a java action to check which are within a circle of 10 miles around the user’s location, calculating the distance between geo locations like suggested here. Closest then means “as the bird flies” btw, not driving distance or anything like that.
This way you don’t have to loop over all of your locations, only a subset that you retrieved first based on longitude and latitude difference.