Project

General

Profile

Bug #8513

N+1 query on compute resource image list

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

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

Description

Seen on the compute resource view page, when loading the images tab over AJAX.

Started GET "/compute_resources/8-example/images" for 127.0.0.1 at 2014-11-26 09:27:14 +0000
Processing by ImagesController#index as HTML
  Parameters: {"compute_resource_id"=>"8-example"}
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 24]]
Setting current user thread-local variable to admin
  AuthSource Load (0.2ms)  SELECT "auth_sources".* FROM "auth_sources" WHERE "auth_sources"."id" = 1 LIMIT 1
  Image Load (0.1ms)  SELECT "images".* FROM "images" LIMIT 1
  ComputeResource Load (0.1ms)  SELECT "compute_resources".* FROM "compute_resources" WHERE "compute_resources"."id" = ? ORDER BY compute_resources.name LIMIT 1  [["id", "8-example"]]
  Image Load (0.5ms)  SELECT "images".* FROM "images" WHERE "images"."compute_resource_id" = 8 LIMIT 10 OFFSET 0
  Operatingsystem Load (0.2ms)  SELECT "operatingsystems".* FROM "operatingsystems" WHERE "operatingsystems"."id" = 6 ORDER BY operatingsystems.name LIMIT 1
  CACHE (0.0ms)  SELECT "operatingsystems".* FROM "operatingsystems" WHERE "operatingsystems"."id" = 6 ORDER BY operatingsystems.name LIMIT 1
  Rendered images/index.html.erb within layouts/application (24.3ms)
  Rendered home/_user_dropdown.html.erb (1.5ms)
  Rendered home/_org_switcher.html.erb (0.0ms)
  Rendered home/_submenu.html.erb (1.7ms)
  Rendered home/_submenu.html.erb (2.4ms)
  Rendered home/_submenu.html.erb (1.7ms)
  Rendered home/_submenu.html.erb (1.6ms)
  Rendered home/_submenu.html.erb (1.9ms)
  Rendered home/_topbar.html.erb (17.1ms)
  Rendered layouts/base.html.erb (47.9ms)
Completed 200 OK in 98.5ms (Views: 75.2ms | ActiveRecord: 1.2ms)
user: dcleal
http://0.0.0.0:3000/compute_resources/8-example/images
N+1 Query detected
  Image => [:operatingsystem]
  Add to your finder: :include => [:operatingsystem]
N+1 Query method call stack
  /home/dcleal/code/foreman/foreman/app/views/images/index.html.erb:19:in `block in _app_views_images_index_html_erb___1356502804056466923_78463940'
  /home/dcleal/code/foreman/foreman/app/views/images/index.html.erb:16:in `_app_views_images_index_html_erb___1356502804056466923_78463940'
  /home/dcleal/code/foreman/foreman/app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
  /home/dcleal/code/foreman/foreman/lib/middleware/catch_json_parse_errors.rb:9:in `call'

Associated revisions

Revision 65e7e1e4 (diff)
Added by Tom Caspy over 4 years ago

fixes #8513 - removing n+1 query from images#index

Revision 7aacbf6e (diff)
Added by Tom Caspy over 4 years ago

fixes #8513 - removing n+1 query from images#index

(cherry picked from commit 65e7e1e40329191a24e41368f3aea16c5a4cd7b6)

History

#1 Updated by Tom Caspy over 4 years ago

  • Status changed from New to Assigned
  • Assignee set to Tom Caspy

#2 Updated by The Foreman Bot over 4 years ago

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

#3 Updated by Tom Caspy over 4 years ago

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

#4 Updated by Dominic Cleal over 4 years ago

  • Legacy Backlogs Release (now unused) set to 29

Also available in: Atom PDF