Project

General

Profile

Bug #13112

N+1 query on hosts#index from last report object

Added by Dominic Cleal about 4 years ago. Updated over 1 year ago.

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

Description

Since #12954, the hosts index is reporting an N+1 database lookup when retrieving the last report object to calculate the host status.

There's an optimisation in #10782 which isn't being used when calling the relevant? method (which now uses the object) as the method doesn't take options including the last report object.


Related issues

Related to Foreman - Bug #12954: Foreman puppet report status does not work without a puppet proxyClosed2015-12-29

Associated revisions

Revision 294ced20 (diff)
Added by Dominic Cleal about 4 years ago

fixes #13112 - add options to HostStatus#relevant? to optimise reports

To match other methods on HostStatus::Status instances, relevant? has a
new options argument which is used from the global status building to
optimise config report loading. This prevents an N+1 query on the
hosts index page.

Previous methods defined with zero arguments are still supported with
a deprecation warning.

Revision a0381819 (diff)
Added by Dominic Cleal about 4 years ago

fixes #13112 - add options to HostStatus#relevant? to optimise reports

To match other methods on HostStatus::Status instances, relevant? has a
new options argument which is used from the global status building to
optimise config report loading. This prevents an N+1 query on the
hosts index page.

Previous methods defined with zero arguments are still supported with
a deprecation warning.

(cherry picked from commit 294ced20fa422e7bb86022d4139f4af91515ef64)

History

#1 Updated by Dominic Cleal about 4 years ago

  • Related to Bug #12954: Foreman puppet report status does not work without a puppet proxy added

#2 Updated by Dominic Cleal about 4 years ago

  • Description updated (diff)

#3 Updated by Dominic Cleal about 4 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal

#4 Updated by Dominic Cleal about 4 years ago

Stack trace:

 | N+1 Query method call stack
 |   /home/dcleal/code/foreman/foreman/app/models/host_status/configuration_status.rb:7:in `last_report'
 |   /home/dcleal/code/foreman/foreman/app/models/host_status/configuration_status.rb:83:in `relevant?'
 |   /home/dcleal/code/foreman/foreman/app/models/host_status/global.rb:10:in `block in build'
 |   /home/dcleal/code/foreman/foreman/app/models/host_status/global.rb:10:in `build'
 |   /home/dcleal/code/foreman/foreman/app/models/host/managed.rb:885:in `build_global_status'
 |   /home/dcleal/code/foreman/foreman/app/helpers/hosts_helper.rb:109:in `host_global_status_icon_class_for_host'
 |   /home/dcleal/code/foreman/foreman/app/helpers/hosts_helper.rb:98:in `name_column'
 |   /home/dcleal/code/foreman/foreman/app/views/hosts/_list.html.erb:22:in `block in _app_views_hosts__list_html_erb___2368167352033240693_98631040'
 |   /home/dcleal/code/foreman/foreman/app/views/hosts/_list.html.erb:17:in `_app_views_hosts__list_html_erb___2368167352033240693_98631040'
 |   /home/dcleal/code/foreman/foreman/app/views/hosts/index.html.erb:4:in `_app_views_hosts_index_html_erb__3208504113801726348_98118920'

#5 Updated by The Foreman Bot about 4 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3055 added

#6 Updated by Dominic Cleal about 4 years ago

  • Legacy Backlogs Release (now unused) changed from 71 to 104

#7 Updated by Dominic Cleal about 4 years ago

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

Also available in: Atom PDF