create table track ( ip int, index ip_index (ip)); create table countries ( ipfrom int not null, ipto int not null, index from_to_index (ipfrom, ipto)); insert into track () values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); insert into countries (ipfrom, ipto) values (1, 10), (2, 9), (3, 8), (4, 7), (5, 6); explain select * from track t, countries c where t.ip >= c.ipfrom and t.ip <= c.ipto; drop table track, countries; create table track ( ip int, index ip_index (ip)); create table countries ( ipfrom int not null, ipto int not null, country char(2) not null, index from_to_index (ipfrom, ipto)); insert into track () values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); insert into countries (ipfrom, ipto) values (1, 10), (2, 9), (3, 8), (4, 7), (5, 6); explain select * from track t, countries c where t.ip >= c.ipfrom and t.ip <= c.ipto;