Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bounding box around within calls to speed up SQL request #87

Merged
merged 12 commits into from
Nov 10, 2015

Conversation

jensb
Copy link
Contributor

@jensb jensb commented Nov 9, 2015

This patch speeds up SQL requests with a radius calculation (in my case 800ms -> 50ms on average) by adding a rectangular bounding box to all within calls on acts_as_mappable objects. This used to be the default for Rails 3, it seems to have been lost in the conversion to ARel. Here it is again.

#geo_scope(options)
with_latlng.where(distance_conditions(options))
# Add bounding box to speed up SQL request.
bounds = formulate_bounds_from_distance(options,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

@@ -293,7 +293,7 @@ def test_ip_geocoder_exception
end

def test_address_geocode
Geokit::Geocoders::MultiGeocoder.expects(:geocode).with('Irving, TX').returns(@location_a)
Geokit::Geocoders::MultiGeocoder.expects(:geocode).with('Irving, TX').twice.returns(@location_a)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [100/80]
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

# Add bounding box to speed up SQL request.
bounds = formulate_bounds_from_distance(
options,
normalize_point_to_lat_lng(options[:origin]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

mnoack pushed a commit that referenced this pull request Nov 10, 2015
Add bounding box around `within` calls to speed up SQL request
@mnoack mnoack merged commit 45ae985 into geokit:master Nov 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants