some query optimizations for sql geoiplookup