Prev | Current Page 253 | Next

Brad Ediger

"Advanced Rails"

FTSearch is available from
http://eigenclass.org/hiki/ftsearch+repository+accessible, and Mauricio has a technical
description at http://eigenclass.org/hiki.rb?simple+full+text+search+engine.
Spatial indexes
Spatial data has a completely different set of requirements than other data, owing
primarily to the types of queries that are typically made against it. Even simple spatial
queries can turn into expensive computational geometry problems.
All major DBMSs have some sort of module for working with spatial data: PostGIS,
MySQL Spatial Extensions, Oracle Spatial, and DB2 Spatial Extender. Most commonly,
these modules use R-tree indexes to categorize spatial objects in the database.
As with any index, defining R-tree indexes must be done manually and takes
some skill. As always, consult your DBMS manual for details.
As usual, there is a lighter-touch option available. The GeoKit library (http://geokit.
rubyforge.org/) can work with latitude and longitude columns in an ordinary database,
doing distance calculations for you. This is great for simple applications that involve a
bit of geospatial data, such as store locators (made possible by GeoKit??™s distance-based
ActiveRecord finders and automatic interface to geocoding web services):
Store.find :all, :origin => '60685', :within => 10, :order => 'distance asc'
ActiveRecord Performance | 171
Updating index statistics
The query planner maintains statistics on each index to decide which one to use during
query planning.


Pages:
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265