Project

General

Profile

Bug #10589

N+1 Query when changing hostgroup from the "All Hosts" page

Added by Ryan Sabatini about 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

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.hostgroup=hg
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.

Foreman N+1.rtf Foreman N+1.rtf 259 KB Ryan Sabatini, 05/22/2015 10:13 AM

Related issues

Related to Foreman - Tracker #11657: Performance refactoring for HostsControllerNew2015-09-02

Associated revisions

Revision 88275be4 (diff)
Added by Tom Caspy almost 4 years ago

fixes #10589 - removing N+1 queries from after_save callbacks when changing hostgroup

Revision 37331501 (diff)
Added by Tom Caspy almost 4 years ago

fixes #10589 - removing N+1 queries from after_save callbacks when changing hostgroup

(cherry picked from commit 88275be4587e98092095c501a8a7f58d7bcfaca4)

History

#1 Updated by Dominic Cleal about 4 years ago

  • Category set to Performance

#2 Updated by Bryan Kearney almost 4 years ago

  • Bugzilla link set to 1257268

#3 Updated by Ohad Levy almost 4 years ago

  • Assignee set to Tom Caspy

#4 Updated by Tom Caspy almost 4 years ago

  • Related to Tracker #11657: Performance refactoring for HostsController added

#5 Updated by The Foreman Bot almost 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2684 added
  • Pull request deleted ()

#6 Updated by Dominic Cleal almost 4 years ago

  • Legacy Backlogs Release (now unused) set to 72

#7 Updated by Tom Caspy almost 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#8 Updated by Dominic Cleal almost 4 years ago

  • Legacy Backlogs Release (now unused) changed from 72 to 88

Also available in: Atom PDF