I'm using the free MaxMind geoip files to do geotargetting on my site I do it the easy way by including the geoip.dat and geoip.inc files would it be faster if I queried a database instead of the geoip.dat file? I can't use the apache module because I'm on a shared host
Typically sending a query to a database would be quicker than using a flat file. Databases are designed to optimise handling and searching large volumes of data which what you need in this instance. Having said that however the only way to know for sure is to compare the speed of each method on your server.
I agree with streety. The performance of db with huge tables can be affected. If you decide to use tables, I'd recommend to use Indexes.
I think there are ways to get data from a file effeciently. even in a shared hosting you can use it. There is no problem at all. You can try this. They update very frequently. More info: http://weirdsilence.net/software/85/
I worked on a script a while ago (using Mysql), you can use it to jumpstart: http://www.free-php-scripts.net/P/Geo_IP Peace,
I find that it's much, much faster with database queries. I just put together a guide for an easy way to do it with Webnet77's IPtoCountry.csv database: http://www.ghoti.ca/2006/11/17/ip-to-country-mapping-for-your-traffic/
thanks ghoti, as it turns out I'm still looking for a solution so I'll definitely read through your guide Is Webnet77's IPtoCountry database accurate? the MaxMind database I was using is 97% accurate
I've found this *free* ip to country database to be very accurate hxxp://ip-to-country.webhosting.info/node/view/6 it's updated every month, only ip to country information, no city, region or state info though.. they also have a few examples of code on how use it hxxp://ip-to-country.webhosting.info/node/view/118
Good tutorial, but I don't think it is advisable to query db on each page load. You can set a cookie after checking the ip once.
i have used it on my sites to target affiliate links to the geolocation of visitors... Conversions went up once i started doing geotargetting this way
Fair enough, I was hoping you may have done something slightly more robust, although how I have no idea. The problem with your approach is that you could probably expect an increase in conversions for a database accuracy level of anything over 50%.
Good point. The visitors to the site I'm using it on right now don't really view more than one page, so I hadn't bothered to think that far. BTW, I also tried MaxMind's GeoIP database yesterday and that also works well... When I get around to needing city-level geo-targeting (in the next few weeks), maybe I'll put together something similar for GeoIP.
I would be wary using city level geolocating. On a country basis these databases are fairly accurate but as the area falls so does the accuracy. I move about quite a bit and in my experience (over the past 4 moves/years) the closest they have been able to identify my location from my ip address is a 20 mile radius. At the moment it is probably approximately 400 miles.