Red Hat Bugzilla – Bug 1257268
N+1 Query when changing hostgroup from the "All Hosts" page
Last modified: 2016-07-27 04:55:04 EDT
I believe there is a N+1 query when modifying a single host or multiple hosts from the "All Hosts" page of the Foreman. Changing a hostgroup from this page is taking ~5-8 minutes to complete depending on the number of hosts being modified.
Found by loading foreman-rake console
hg = Hostgroup.find_by_id(1)
h = Host.find_by_name("name of host")
h.save(:validate => false)
I've attached the specific query that I believe has the N+1. It is executed several times in this block of code which I think is the reason the host group change takes such a long time to complete.
Created from redmine issue http://projects.theforeman.org/issues/10589
Upstream bug component is Provisioning
Upstream bug component is Performance
Upstream bug assigned to email@example.com
Moving to POST since upstream bug http://projects.theforeman.org/issues/10589 has been closed
Applied in changeset commit:88275be4587e98092095c501a8a7f58d7bcfaca4.
Verified, as best as I can tell - there's not a number of hosts given for when the performance impact occurs. however, I tried changing the host group on 10 hosts at once, and it was (nearly) instant.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.