Project

General

Profile

Actions

Bug #25577

closed

Configure -> Smart class parameters page took long time to load

Added by Shimon Shtein about 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Parameters
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1643847

Description of problem:
Configure -> Smart class parameters page may take long time to load when they are hundreds of puppet environments and puppet classes.

The issue appears to be the "eager_load" joins which may be very expensive when there are too many rows. When I try to use "includes" instead of eager_load, the page load many times faster. Previously it spent 170+ seconds to load the page, now only ~5seconds or less.

  1. diff u /tmp/puppetclass_lookup_keys_controller.rb.orig /usr/share/foreman/app/controllers/puppetclass_lookup_keys_controller.rb
    --
    /tmp/puppetclass_lookup_keys_controller.rb.orig 2018-10-29 18:06:04.103966839 1000
    ++ /usr/share/foreman/app/controllers/puppetclass_lookup_keys_controller.rb 2018-10-29 18:08:03.990375270 +1000
    @ -4,7 +4,7 @
    before_action :setup_search_options, :only => :index

    def index
    - @lookup_keys = resource_base_search_and_page(:param_classes).smart_class_parameters
    + @lookup_keys = resource_base_search_and_page.includes(:param_classes).distinct.smart_class_parameters
    @puppetclass_authorizer = Authorizer.new(User.current, :collection => @lookup_keys.map{|key| key.param_class.try(:id)}.compact.uniq)
    end

Actions

Also available in: Atom PDF