Skip to content
Advertisement

MariaDB/MySQL joining tables on a range

I have a table which includes an IP address:

and another table with an IP range:

I am trying to join both tables with the following “on” expression.

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!

Advertisement

Answer

One possibility is:

This can then take advantage of indexes on ip2location_db1(ip_to).

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement