Project

General

Profile

« Previous | Next » 

Revision 7fabb50a

Added by Daniel Lobato Garcia almost 8 years ago

Fixes #15527 - api/v2/hosts is slow loading permissions

The .eager_load call when called with [] generates a SELECT query that
selects all host attributes. This can cause it to take a lot longer
when there are large number of hosts involved. These attributes are
irrelevant in this context (when they are relevant, they're put in the
scope_components hash)

With 5700 hosts, it takes about 50% less time to run this than to run
it with eager_load.

Chaining the call with .where makes the call near-instant.
It selects the host from the list of hosts we can see using the db
directly.

(cherry picked from commit 1ff7e25908f81912458a0fd85c421fb5feeb90a1)

  • added
  • modified
  • copied
  • renamed
  • deleted