-
Notifications
You must be signed in to change notification settings - Fork 244
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
Conversation
#geo_scope(options) | ||
with_latlng.where(distance_conditions(options)) | ||
# Add bounding box to speed up SQL request. | ||
bounds = formulate_bounds_from_distance(options, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
Add bounding box around `within` calls to speed up SQL request
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 onacts_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.