Project

General

Profile

Actions

Refactor #39198

open

Use bulk inserts when importing new facts for a persisted host

Added by Pablo Méndez Hernández 5 months ago. Updated about 1 month ago.

Status:
Ready For Testing
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

  1. 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.

  1. 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.

Actions #1

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
Actions #2

Updated by The Foreman Bot 3 months ago

  • Pull request deleted (https://github.com/theforeman/foreman/pull/10942)
Actions #3

Updated by Pablo Méndez Hernández 3 months ago

Split into two separate issues per review feedback:
- #39298 — Bulk insert for fact values
- #39299 — Additive fact import mode

Closing this one.

Actions #4

Updated by Ewoud Kohl van Wijngaarden about 1 month ago

  • Red Hat JIRA set to SAT-43838
Actions

Also available in: Atom PDF