diff --git a/service/lib/agama/dbus/software/manager.rb b/service/lib/agama/dbus/software/manager.rb index edb08962bd..fb2e5f9a20 100644 --- a/service/lib/agama/dbus/software/manager.rb +++ b/service/lib/agama/dbus/software/manager.rb @@ -79,6 +79,8 @@ def initialize(backend, logger) dbus_method :ListPatterns, "in Filtered:b, out Result:a{s(ssssi)}" do |filtered| [ backend.patterns(filtered).each_with_object({}) do |pattern, result| + # make sure all attributes are already preloaded, adjust the "patterns" method + # in service/lib/agama/software/manager.rb when changing this list value = [ pattern.category, pattern.description, diff --git a/service/lib/agama/software/manager.rb b/service/lib/agama/software/manager.rb index 4152e3bfaf..d891259df0 100644 --- a/service/lib/agama/software/manager.rb +++ b/service/lib/agama/software/manager.rb @@ -184,7 +184,10 @@ def provision_selected?(tag) # Filtering criteria can change. # @return [Array] def patterns(filtered) - patterns = Y2Packager::Resolvable.find(kind: :pattern) + # huge speed up, preload the used attributes to avoid querying libzypp again, + # see "ListPatterns" method in service/lib/agama/dbus/software/manager.rb + preload = [:category, :description, :icon, :summary, :order, :user_visible] + patterns = Y2Packager::Resolvable.find({ kind: :pattern }, preload) patterns = patterns.select(&:user_visible) if filtered patterns