Skip to content
Snippets Groups Projects
Commit bc3954b2 authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge pull request #726 from toothrot/master

Limit maxmind local subselect query to reduce cost
parents 3a362ba7 523ab260
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,7 @@ module Geocoder::Lookup
addr = IPAddr.new(query.text).to_i
q = "SELECT l.country, l.region, l.city, l.latitude, l.longitude
FROM maxmind_geolite_city_location l WHERE l.loc_id = (SELECT b.loc_id FROM maxmind_geolite_city_blocks b
WHERE b.start_ip_num <= #{addr} AND #{addr} <= b.end_ip_num)"
WHERE b.start_ip_num <= #{addr} AND #{addr} <= b.end_ip_num LIMIT 1)"
format_result(q, [:country_name, :region_name, :city_name, :latitude, :longitude])
elsif configuration[:package] == :country
addr = IPAddr.new(query.text).to_i
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment