Project

General

Profile

Actions

Bug #14050

closed

N+1 query on hosts#index from host's build token

Added by Dominic Cleal almost 9 years ago. Updated over 6 years ago.

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

Description

When accessing the hosts#index since #5883, the UI's performing a N+1 database lookup to find the tokens to calculate the build status.

 | http://0.0.0.0:3000/hosts
 | N+1 Query detected
 |   Host::Managed => [:token]
 |   Add to your finder: :includes => [:token]
 | N+1 Query method call stack
 |   /home/dcleal/code/foreman/foreman/app/models/host/managed.rb:266:in `token_expired?'
 |   /home/dcleal/code/foreman/foreman/app/models/host_status/build_status.rb:54:in `token_expired?'
 |   /home/dcleal/code/foreman/foreman/app/models/host_status/build_status.rb:35:in `to_status'
 |   /home/dcleal/code/foreman/foreman/app/models/host_status/build_status.rb:25:in `to_global'
 |   /home/dcleal/code/foreman/foreman/app/models/host_status/global.rb:19:in `block in build'
 |   /home/dcleal/code/foreman/foreman/app/models/host_status/global.rb:19:in `map'
 |   /home/dcleal/code/foreman/foreman/app/models/host_status/global.rb:19:in `build'
 |   /home/dcleal/code/foreman/foreman/app/models/host/managed.rb:878: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__717094616139966240_70130187070520'
 |   /home/dcleal/code/foreman/foreman/app/views/hosts/_list.html.erb:17:in `_app_views_hosts__list_html_erb__717094616139966240_70130187070520'
 |   /home/dcleal/code/foreman/foreman/app/views/hosts/index.html.erb:4:in `_app_views_hosts_index_html_erb__4161764017543335258_99759220'

The tokens need to be preloaded in the same way that the last report is in #10782, #13112.


Related issues 1 (0 open1 closed)

Related to Foreman - Bug #5883: Host: provide user indication that the build token has expiredClosedJulien Pivotto05/22/2014Actions
Actions #1

Updated by Dominic Cleal almost 9 years ago

  • Related to Bug #5883: Host: provide user indication that the build token has expired added
Actions #2

Updated by The Foreman Bot almost 9 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Tom Caspy
  • Pull request https://github.com/theforeman/foreman/pull/3340 added
Actions #3

Updated by Tom Caspy over 8 years ago

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

Also available in: Atom PDF