Hello,
on 01/12/2005 08:48 PM Wendell Frohwein said the following:
I was hoping on the based on the operation of the script, someone would suggest a better and faster way to search zip code radius, while matching the results to agents within the system.
I assume you are using a script like this that computes the geographic distance to each zip code in the database:
http://www.phpclasses.org/phpziplocator
The problem of the computing the distance to each zip code in the database is that it prevents the use of any index and so it leads inevitably to a full table scan. The more zip codes in the database, the worst it gets.
A more efficient solution would use a range clause to exclude all zip codes with coordinates that are farther than the desired radius considering only the longitudinal and latitudinal distance separately. This would allow the use of eventual indexes in the latitude or longitude fields to avoid full table scan.
This is more like the approach of this other class despite in the end it does not consider the actual radial distance like the class above.
http://www.phpclasses.org/zipcodesrange
I am not sure if these explanations were clear to you. Just take a look at the classes and let me know if you got the idea.
--
Regards, Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php