Actions
Refactor #8761
openImprove performance of external search methods (of scoped_search)
Description
Not sure, if the performance is the issue here, but the improvement can be made following way:
Currently, many of the :ext_method of scoped_search are defined like:
hostgroups += Hostgroup.unscoped.with_taxonomy_scope.joins(:host_config_groups).where("host_config_groups.config_group_id IN (#{config_group_ids.join(',')})")
hostgroup_ids = hostgroups.map(&:subtree_ids).flatten.uniq
{ :conditions => "hostgroups.id IN(#{hostgroup_ids.join(',')})" }
That effectively leads to N+1 query. The found IDs needs to be parsed by Ruby to memory and back.
I have found a easy way to overcome this by defining the query using Arel and calling to_sql on it. Example: https://github.com/OpenSCAP/foreman_openscap/commit/a504cdf716b96fae8a6ab7353fca27bf23912852
Updated by Kavita Gaikwad almost 8 years ago
- Assignee set to Kavita Gaikwad
- Target version set to 1.15.6
Actions