Project

General

Profile

Refactor #25053

Run expensive db_facts query just once and unordered

Added by Lukas Zapletal 3 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Category:
Facts
Target version:
-
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

It looks like this query is very expensive on MySQL: host.fact_values.where(:fact_name => fact_names.values).reorder('')

We call it twice currently while it is not needed to run this query twice, we can fetch the list of fact value IDs stored in database in update step and prepare list of facts to be added in the next step in advance.

Also we order the query by ID for some reason, we can process them unordered just fine.

https://community.theforeman.org/t/foreman-1-18-2-fact-query-on-puppet-report-upload-fact-import-incredibly-slow/11238

Associated revisions

Revision ce5bf100 (diff)
Added by Lukas Zapletal 2 months ago

Fixes #25053 - expensive db_facts query executed just once

Revision 37b9fa1a (diff)
Added by Tomer Brisker 2 months ago

Refs #25053 - Remove unused fact_names_by_id hash

History

#1 Updated by The Foreman Bot 3 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/6093 added

#2 Updated by The Foreman Bot 2 months ago

  • Pull request https://github.com/theforeman/foreman/pull/6108 added

#3 Updated by The Foreman Bot 2 months ago

  • Pull request https://github.com/theforeman/foreman/pull/6130 added

#4 Updated by Tomer Brisker 2 months ago

  • Fixed in Releases 1.20.0 added
  • Pull request deleted (https://github.com/theforeman/foreman/pull/6108)

#5 Updated by Lukas Zapletal 2 months ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF