Skip to content

Commit

Permalink
Indexing notes based on feedback from engineering support at Blue Box…
Browse files Browse the repository at this point in the history
  • Loading branch information
monde committed Sep 7, 2009
1 parent 93a264b commit c46c2b1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.markdown
Expand Up @@ -489,6 +489,26 @@ If you need to sort things post-query, you can do so:
Obviously, each of the items in the array must have a latitude/longitude so
they can be sorted by distance.

## Database indexes

MySQL can't create indexes on a calculated field such as those Geokit uses to
calculate distance based on latitude/longitude values for a record. However,
indexing the lat and lng columns does improve Geokit distance calculation
performance since the lat and lng columns are used in a straight comparison
for distance calculation. Assuming a Page model that is incorporating the
Geokit plugin the migration would be as follows.

class AddIndexOPageLatAndLng < ActiveRecord::Migration

def self.up
add_index :pages, [:lat, :lng]
end

def self.down
remove_index :pages, [:lat, :lng]
end
end

## Database Compatability

* Geokit works with MySQL (tested with version 5.0.41) or PostgreSQL (tested with version 8.2.6)
Expand Down

0 comments on commit c46c2b1

Please sign in to comment.