ruby on rails - Is it necessary to add index to latitude and longitude fields -
i using rails
, geocoder
gem postgres
database. therefore have add latitude
, longitude
fields database. speaking isnt better add indexing fields faster querying?
if end querying database records using latitude , longitude, you'll benefit adding index. indexes used not exact matching queries, comparison queries, such select * table_name latitude between 30 , 40 , longitude > 50
. depending on queries , number of records, postgres query planner choose optimal way find matching records (either sequential scan, or index scan).
Comments
Post a Comment