[edit] - as pointed out to me in the comments I should have noted that I will be using a LAMP based architecture, meaning a MySQL database. Sorry about forgetting to mention this.
I have to create a PHP backend for an iPhone app. The app sends up the users coords and requests the closes 10 local users.
I'm just wondering what is the most efficient way to determine this, I dont want to have to scan the entire table of users, calculate the distance between their geo-coords and the target & order them from lowest to farthest.
Can anyone suggest a more elegant solution instead of scanning all the users? Thanks for your time.