geokit / geokit-rails

Official Geokit plugin for Rails/ActiveRecord. Provides location-based goodness for your Rails app. Requires the Geokit gem.
MIT License
1.57k stars 245 forks source link

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

Closed jensb closed 8 years ago

jensb commented 8 years ago

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.