您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

改善查询时间的sql ip查找数据库

改善查询时间的sql ip查找数据库

这是如何执行的?我希望它应该使用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
SQLServer 2022/1/1 18:52:49 有308人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶