I have a database with roughly ~ 100,000 entries of IP ranges which my website will reject requests from.
The table storing these ranges is in the format
ip_from (int)
ip_to (int)
Using PHP I convert the users IP to the integer value using ip2long
I then use the following SQL query to determine whether the users IP is present in a range in the table.
SELECT `ip_from`
FROM `ip2location_proxy`
WHERE '".$ip."' BETWEEN ip_from AND ip_to LIMIT 1
The issue is that this is creating large server load. I'm wondering if anyone can suggest a better method for detecting if the IP is within a range specified in the database, such as an alternative to using the BETWEEN
command.