Bug #27332
List all hosts page in an organization takes long time when there is a lot of reports
Description
Description of problem:
Satellite is taking long time to load the All Host page in an organization when there is a lot of reports.
There is a default scope in "app/models/foreman_openscap/arf_report.rb"
default_scope do
with_taxonomy_scope do
order("#{self.table_name}.created_at DESC")
end
end
With "Organization.current" set, the above function will try to filter the reports by organization. This seems to cause ruby to take long time to construct a list of report ids in an organization to be filtered when there is a lot of reports in an organization.
Version-Release number of selected component (if applicable):
6.5
Steps to Reproduce:
1. Need to have many content hosts that run openscap scan and upload the reports to the Satellite.
2. Make sure "Any organization" is set
3. Go to Hosts -> All Hosts page
4. The page should finish loading within an acceptable time.
5. Now, set the organization.
6. Refresh the "All Hosts" page again
7. The page will take several minutes to load.
Actual results:
"All hosts" page takes long time to load
Expected results:
"All hosts" page should finish loading within an acceptable time.
Related issues
Associated revisions
History
#1
Updated by The Foreman Bot almost 4 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman_openscap/pull/402 added
#2
Updated by The Foreman Bot almost 4 years ago
- Fixed in Releases foreman_openscap 1.0.5 added
#3
Updated by Ondřej Pražák almost 4 years ago
- Status changed from Ready For Testing to Closed
#4
Updated by Ondřej Pražák almost 4 years ago
- Related to Bug #26760: Audits page is very slow added
Fixes #27332 - Speed up the Arf reports loading for host
Having many reports will dramatically slow down the query to retrieve
reports for a host when Organization.current is set. This triggers the
default scope to filter the reports by Organization. If there are millions
of reports to be filtered, Foreman will spend extremely long time to
construct the report ids to be filtered and also slow down the db query.
This commit fixed the issue by preventing Foreman to run the default scope.