Actions
Bug #14050
closedN+1 query on hosts#index from host's build token
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.
Updated by Dominic Cleal over 8 years ago
- Related to Bug #5883: Host: provide user indication that the build token has expired added
Updated by The Foreman Bot over 8 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
Updated by Tom Caspy over 8 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 9738552ed6daaf27455151910e0353c8aec41c7e.
Actions