I have a table which includes an IP address:
create table login_history
(
    id         int auto_increment primary key,
    ip         int unsigned,
    created    datetime(6)  not null,
    user_id    int unsigned not null,
);
and another table with an IP range:
create table ip2location
(
    ip_from      int unsigned not null primary key,
    ip_to        int unsigned null,
    country_code char(2)      null,
)
I am trying to join both tables with the following "on" expression.
select * from login_history
left join ip2location_db1  on
    ip2location_db1.ip_from <= login_history.ip_int and ip2location_db1.ip_to >= login_history.ip_int
It's working fine, but it's very slow. How can I improve the performance of such a query? I already added indices on the IP columns of both tables.
Thank you for your help. Have a nice day!