From 8307f2af5fdb634532c29f0b7ad17401298ea1b9 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Tue, 24 Jan 2017 09:28:54 +0100 Subject: [PATCH] Associate subnets with routers with less queries Associate subnets with routers with less queries, 50% of the DB queries exactly. --- app/models/ems_refresh/save_inventory_network.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/models/ems_refresh/save_inventory_network.rb b/app/models/ems_refresh/save_inventory_network.rb index fa7c7f10472..3c476e47f5c 100644 --- a/app/models/ems_refresh/save_inventory_network.rb +++ b/app/models/ems_refresh/save_inventory_network.rb @@ -405,12 +405,8 @@ def save_load_balancer_health_check_members_inventory(load_balancer_health_check def link_cloud_subnets_to_network_routers(hashes) return if hashes.blank? - cloud_subnets = CloudSubnet.where(:id => hashes.map { |x| x[:id] }.compact.uniq).find_each.index_by(&:id) - hashes.each do |hash| - network_router = hash.fetch_path(:network_router, :id) - cloud_subnet = cloud_subnets[hash[:id]] - cloud_subnet.update_attributes(:network_router_id => network_router) if cloud_subnet + CloudSubnet.where(:id => hash[:id]).update_all(:network_router_id => hash.fetch_path(:network_router, :id)) end end end