pezholio/UK-Postcodes — pull request #5 by ivebeenlinuxed (2012-11-05 12:19:12+00:00)
Title: Improve reverse geocode query

After a few days running, it seems that the MySQL query used for latlng to postcode needed some revision work.

Before this commit the logs shows that most of the MySQL time was spent ordering the results and doing the maths.

This fix adds a "WHERE" clause, denoting an approximate 20 mile range to "short list" the geolocation. By doing this the application is only searching a limited number of postcodes in depth, rather than performing mathematics and ordering on the entire table.

See the improvements (home PC, hense the slow file_get_contents on HTTP request) here: http://twitpic.com/bajqto/full

This fix speeds up requests from approximately 10 seconds to 0.3 seconds.