Refactor #39198
openUse bulk inserts when importing new facts for a persisted host
Description
- Problem
During host registration, `FactImporter#add_new_facts` inserts each new fact individually via `host.fact_values.create!` inside a loop. With 193 RHSM facts per registration, this produces 193 individual INSERT statements within a single transaction.
Under concurrent bulk registration (500-1000 hosts), this multiplies to hundreds of thousands of sequential INSERTs, significantly increasing database pressure and prolonging the critical `POST /rhsm/consumers` registration path.
- Fix
For persisted hosts (where `host_id` is known), replace the per-fact loop with a single `FactValue.insert_all` call. The `host.new_record?` path is preserved as-is since bulk insert requires a host_id.
This reduces 193 individual INSERTs to a single statement per registration, consistent with how other bulk data is handled elsewhere in the codebase.
Updated by The Foreman Bot 5 months ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/10942 added
Updated by The Foreman Bot 3 months ago
- Pull request deleted (
https://github.com/theforeman/foreman/pull/10942)
Updated by Ewoud Kohl van Wijngaarden about 1 month ago
- Red Hat JIRA set to SAT-43838