I currently have an app that has been deployed for two years now that has a massive number of objects in it. When a user searches I do a find on all these objects and then go through the objects and look for the search string in a number of fields in the object and related objects. This uses up too much memory and my server is throwing 500s. I was hoping to get some help writing an SQL query that will do the search and only instantiate objects that meet the criteria instead of all objects.
I need something that will do a like on several fields, some in other tables involving joins.
So something that does a like for a keyword on the following fields
problem, site.user.firstname, worker.company
where problem is in the current model and site and worker are related models using has_one
Any advice is appreciated.