I have a database named coordinates, with several different locations, and their corresponding longitude and latitude (both as a float(10,6) value).
What I would like to do is to take a user's known location ($longitude, $latitude), and then search this database to find the closet matches.
I can do this now by calculating the distance:
$query=mysql_query("SELECT *, (SQRT((69.1*(latitude-$latitude))*(69.1*(latitude-$latitude))+(69.1*(longitude-$longitude)*cos($latitude/57.3))*(69.1*(longitude-$longitude)*cos($latitude/57.3)))*5280) AS distance FROM coordinates ORDER BY distance ASC");
That would output the database, with a new column called distance (in feet). The top of the list would be the closest, and the bottom of the list would be the furthest away.
Right now my database is small. My question is would this be a horrific database query if I had a larger database? And if it is, how can I tame this query? Or, is this something that the computer can easily churn through, and I don't need to worry about it.