From 6296c6044b096edc6d45bd83017f504163e9f785 Mon Sep 17 00:00:00 2001 From: Greg McCullough Date: Tue, 22 May 2018 15:45:25 -0400 Subject: [PATCH] Merge pull request #17402 from NickLaMuro/lighter_queries_in_miq_request_workflow Avoid duplicate host load in allowed_hosts_obj (cherry picked from commit d577df7a6d6f28c24264a65b30d7011db1d6d71a) https://bugzilla.redhat.com/show_bug.cgi?id=1593797 --- app/models/miq_request_workflow.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/miq_request_workflow.rb b/app/models/miq_request_workflow.rb index 7ae9cff72cd..81a2f4c9612 100644 --- a/app/models/miq_request_workflow.rb +++ b/app/models/miq_request_workflow.rb @@ -1046,7 +1046,7 @@ def allowed_hosts_obj(options = {}) return [] if hosts_ids.blank? # Remove any hosts that are no longer in the list - all_hosts = load_ar_obj(src[:ems]).hosts.find_all { |h| hosts_ids.include?(h.id) } + all_hosts = load_ar_obj(src[:ems]).hosts.where(:id => hosts_ids) allowed_hosts_obj_cache = process_filter(:host_filter, Host, all_hosts) _log.info("allowed_hosts_obj returned [#{allowed_hosts_obj_cache.length}] objects in [#{Time.now - st}] seconds") rails_logger('allowed_hosts_obj', 1)