Actions
Bug #39381
openhosts index page loads full Host objects when only hostgroup_ids are needed
Description
The `summarise_report_metrics` action in `HostsController` calls:
@hosts.map(&:hostgroup_id).compact.uniq
This loads all Host ActiveRecord objects already fetched for the page
into Ruby memory and extracts `hostgroup_id` in application code.
Using `pluck` instead:
@hosts.pluck(:hostgroup_id).compact.uniq
generates a `SELECT hostgroup_id FROM hosts WHERE ...` query that
returns only the needed column, avoiding unnecessary object allocation.
This is measurable on the hosts index page when displaying many hosts.
Updated by The Foreman Bot 18 days ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/10951 added
Actions