mysql> SELECT IPRange.ipRangeId, IPRange.addedOn, IPRange.ipFrom, IPRange.ipTo, IPRange.ipRangeIP2CityLink, IP2City.ip2CityId, IP2City.addedOn, IP2City.ipRangeIP2CityLink, IP2City.countryShort, IP2City.regionId, IP2City.cityId, City.cityId, City.addedOn, City.countryShort, City.regionShort, City.cityLong, Region.regionId, Region.addedOn, Region.countryShort, Region.regionShort, Region.regionLong, locality.Country.countryId, locality.Country.addedOn, locality.Country.countryShort, locality.Country.countryLong FROM IPRange LEFT JOIN IP2City ON IPRange.ipRangeIP2CityLink = IP2City.ipRangeIP2CityLink LEFT JOIN locality.Country ON IP2City.countryShort = locality.Country.countryShort LEFT JOIN Region ON IP2City.regionId = Region.regionId LEFT JOIN City ON IP2City.cityId = City.cityId WHERE ipTo >= 2057920169 limit 1; +-----------+---------------------+------------+------------+--------------------+-----------+---------------------+--------------------+--------------+----------+--------+--------+---------------------+--------------+-------------+-----------+----------+---------------------+--------------+-------------+------------+-----------+---------------------+--------------+-------------+ | ipRangeId | addedOn | ipFrom | ipTo | ipRangeIP2CityLink | ip2CityId | addedOn | ipRangeIP2CityLink | countryShort | regionId | cityId | cityId | addedOn | countryShort | regionShort | cityLong | regionId | addedOn | countryShort | regionShort | regionLong | countryId | addedOn | countryShort | countryLong | +-----------+---------------------+------------+------------+--------------------+-----------+---------------------+--------------------+--------------+----------+--------+--------+---------------------+--------------+-------------+-----------+----------+---------------------+--------------+-------------+------------+-----------+---------------------+--------------+-------------+ | 985474 | 2007-03-05 19:46:55 | 2057899776 | 2058354687 | 24572 | 24572 | 2007-03-05 19:36:02 | 24572 | IN | 1714 | 10707 | 10707 | 2007-03-05 19:31:41 | IN | 07 | New Delhi | 1714 | 2007-03-05 19:31:00 | IN | 07 | Delhi | 10 | 2007-03-05 19:52:14 | IN | India | +-----------+---------------------+------------+------------+--------------------+-----------+---------------------+--------------------+--------------+----------+--------+--------+---------------------+--------------+-------------+-----------+----------+---------------------+--------------+-------------+------------+-----------+---------------------+--------------+-------------+ 1 row in set (0.03 sec) mysql> SELECT IPRange.ipRangeId, IPRange.addedOn, IPRange.ipFrom, IPRange.ipTo, IPRange.ipRangeIP2CityLink, IP2City.ip2CityId, IP2City.addedOn, IP2City.ipRangeIP2CityLink, IP2City.countryShort, IP2City.regionId, IP2City.cityId, City.cityId, City.addedOn, City.countryShort, City.regionShort, City.cityLong, Region.regionId, Region.addedOn, Region.countryShort, Region.regionShort, Region.regionLong, locality.Country.countryId, locality.Country.addedOn, locality.Country.countryShort, locality.Country.countryLong FROM IPRange LEFT JOIN IP2City ON IPRange.ipRangeIP2CityLink = IP2City.ipRangeIP2CityLink LEFT JOIN locality.Country ON IP2City.countryShort = locality.Country.countryShort LEFT JOIN Region ON IP2City.regionId = Region.regionId LEFT JOIN City ON IP2City.cityId = City.cityId WHERE 2057920169 between ipFrom and ipTo limit 1; +-----------+---------------------+------------+------------+--------------------+-----------+---------------------+--------------------+--------------+----------+--------+--------+---------------------+--------------+-------------+-----------+----------+---------------------+--------------+-------------+------------+-----------+---------------------+--------------+-------------+ | ipRangeId | addedOn | ipFrom | ipTo | ipRangeIP2CityLink | ip2CityId | addedOn | ipRangeIP2CityLink | countryShort | regionId | cityId | cityId | addedOn | countryShort | regionShort | cityLong | regionId | addedOn | countryShort | regionShort | regionLong | countryId | addedOn | countryShort | countryLong | +-----------+---------------------+------------+------------+--------------------+-----------+---------------------+--------------------+--------------+----------+--------+--------+---------------------+--------------+-------------+-----------+----------+---------------------+--------------+-------------+------------+-----------+---------------------+--------------+-------------+ | 985474 | 2007-03-05 19:46:55 | 2057899776 | 2058354687 | 24572 | 24572 | 2007-03-05 19:36:02 | 24572 | IN | 1714 | 10707 | 10707 | 2007-03-05 19:31:41 | IN | 07 | New Delhi | 1714 | 2007-03-05 19:31:00 | IN | 07 | Delhi | 10 | 2007-03-05 19:52:14 | IN | India | +-----------+---------------------+------------+------------+--------------------+-----------+---------------------+--------------------+--------------+----------+--------+--------+---------------------+--------------+-------------+-----------+----------+---------------------+--------------+-------------+------------+-----------+---------------------+--------------+-------------+ 1 row in set (0.03 sec) mysql> explain SELECT IPRange.ipRangeId, IPRange.addedOn, IPRange.ipFrom, IPRange.ipTo, IPRange.ipRangeIP2CityLink, IP2City.ip2CityId, IP2City.addedOn, IP2City.ipRangeIP2CityLink, IP2City.countryShort, IP2City.regionId, IP2City.cityId, City.cityId, City.addedOn, City.countryShort, City.regionShort, City.cityLong, Region.regionId, Region.addedOn, Region.countryShort, Region.regionShort, Region.regionLong, locality.Country.countryId, locality.Country.addedOn, locality.Country.countryShort, locality.Country.countryLong FROM IPRange LEFT JOIN IP2City ON IPRange.ipRangeIP2CityLink = IP2City.ipRangeIP2CityLink LEFT JOIN locality.Country ON IP2City.countryShort = locality.Country.countryShort LEFT JOIN Region ON IP2City.regionId = Region.regionId LEFT JOIN City ON IP2City.cityId = City.cityId WHERE ipTo >= 2057920169 limit 1\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: IPRange type: range possible_keys: ipTo key: ipTo key_len: 8 ref: NULL rows: 721578 Extra: Using where *************************** 2. row *************************** id: 1 select_type: SIMPLE table: IP2City type: eq_ref possible_keys: ipRangeIP2CityLink key: ipRangeIP2CityLink key_len: 4 ref: locality.IPRange.ipRangeIP2CityLink rows: 1 Extra: *************************** 3. row *************************** id: 1 select_type: SIMPLE table: Country type: eq_ref possible_keys: countryShort key: countryShort key_len: 2 ref: locality.IP2City.countryShort rows: 1 Extra: *************************** 4. row *************************** id: 1 select_type: SIMPLE table: Region type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 4146 Extra: *************************** 5. row *************************** id: 1 select_type: SIMPLE table: City type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 147232 Extra: 5 rows in set (0.00 sec) mysql> explain SELECT IPRange.ipRangeId, IPRange.addedOn, IPRange.ipFrom, IPRange.ipTo, IPRange.ipRangeIP2CityLink, IP2City.ip2CityId, IP2City.addedOn, IP2City.ipRangeIP2CityLink, IP2City.countryShort, IP2City.regionId, IP2City.cityId, City.cityId, City.addedOn, City.countryShort, City.regionShort, City.cityLong, Region.regionId, Region.addedOn, Region.countryShort, Region.regionShort, Region.regionLong, locality.Country.countryId, locality.Country.addedOn, locality.Country.countryShort, locality.Country.countryLong FROM IPRange LEFT JOIN IP2City ON IPRange.ipRangeIP2CityLink = IP2City.ipRangeIP2CityLink LEFT JOIN locality.Country ON IP2City.countryShort = locality.Country.countryShort LEFT JOIN Region ON IP2City.regionId = Region.regionId LEFT JOIN City ON IP2City.cityId = City.cityId WHERE 2057920169 between ipFrom and ipTo limit 1\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: IPRange type: range possible_keys: ipFrom,ipTo key: ipTo key_len: 8 ref: NULL rows: 721578 Extra: Using where *************************** 2. row *************************** id: 1 select_type: SIMPLE table: IP2City type: eq_ref possible_keys: ipRangeIP2CityLink key: ipRangeIP2CityLink key_len: 4 ref: locality.IPRange.ipRangeIP2CityLink rows: 1 Extra: *************************** 3. row *************************** id: 1 select_type: SIMPLE table: Country type: eq_ref possible_keys: countryShort key: countryShort key_len: 2 ref: locality.IP2City.countryShort rows: 1 Extra: *************************** 4. row *************************** id: 1 select_type: SIMPLE table: Region type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 4146 Extra: *************************** 5. row *************************** id: 1 select_type: SIMPLE table: City type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 147232 Extra: 5 rows in set (0.01 sec)