表有100,845行。我正在尝试通过IP(ip2long)在特定国家/地区的IP范围内检测国家/地区。
SELECT `country_code` FROM `geo_ip_country`
WHERE 3271557119 BETWEEN `start_ip_long` AND `end_ip_long`
start_ip_long
和end_ip_long
都已编入索引。但是根据explain query
,查询不使用索引并执行全表扫描,所有100,845行。
id select_type table type possible_keys rows Extra
1 SIMPLE geo_ip_country ALL key_name 100845 Using where
我试过了:
start_ip_long
AND end_ip_long
start_ip_long
如何优化此查询或表以便在这种情况下使用索引?