Project

General

Profile

Actions

Bug #11860

open

N+1 query on API hosts#show from inherited parameters

Added by Dominic Cleal about 9 years ago. Updated about 9 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Performance
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

#11763 introduced an N+1 query to the hosts#show API by not preloading inherited parameters.

 | N+1 Query detected
 |   Hostgroup => [:group_parameters]
 |   Add to your finder: :includes => [:group_parameters]
 | N+1 Query method call stack
 |   /home/dcleal/code/foreman/foreman/app/models/host/managed.rb:486:in `block in host_inherited_params_objects'
 |   /home/dcleal/code/foreman/foreman/app/models/host/managed.rb:486:in `each'
 |   /home/dcleal/code/foreman/foreman/app/models/host/managed.rb:486:in `host_inherited_params_objects'
 |   /home/dcleal/code/foreman/foreman/app/views/api/v2/hosts/show.json.rabl:3:in `_app_views_api_v__hosts_show_json_rabl___1881208653962415019_70117806892400'
 |   /home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:151:in `disable_json_root'
 |   /home/dcleal/code/foreman/foreman/app/controllers/concerns/application_shared.rb:13:in `set_timezone'
 |   /home/dcleal/code/foreman/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 |   /home/dcleal/code/foreman/foreman/lib/middleware/catch_json_parse_errors.rb:9:in `call'

I think this is triggered by using a nested host group, so it's N+1 due to multiple levels of host group inheritance.


Related issues 1 (0 open1 closed)

Related to Foreman - Bug #11763: Host API does not return all parameters (e.g. from locations, et al.)ClosedShlomi Zadok09/10/2015Actions
Actions

Also available in: Atom PDF