I have a location text field hooked up to the jquery plugin EasyAutocomplete:
It's working, but the problem is the dataset is large - 100,000 records or so. It takes an unacceptably long time to match any results.
I have a json endpoint in my app that loads the records for the autocomplete. The code in the Rails controller looks like this:
def index
@locations = Location.select(:id,:canonical_name)
respond_to do |format|
format.json { render json: @locations }
end
end
So far what I've tried is putting an index on the canonical_name
column, and putting a Rails.cache.fetch
around the loading of the records, but neither of these things helped much.
What can be done to speed up this operation?