这是如何执行的?我希望它应该使用ipto上的索引查找来快速解析顶部,使用ipfrom上的索引查找来解析底部和2个(或可能一个)书签查找以返回其余的列。
SELECT id, ipfrom, ipto, countrycode, countryname,region,city FROM
(
SELECT TOP 1 id, ipfrom, ipto, countrycode, countryname,region,city
FROM tbl_ip
WHERE @ip <= ipto
ORDER BY ipto
INTERSECT
SELECT TOP 1 id, ipfrom, ipto, countrycode, countryname,region,city
FROM tbl_ip
WHERE ipfrom <= @ip
ORDER BY ipfrom DESC
) ip