Missing Bulk Operation (ARCH6053)
Key ruby.orm.missing-bulk-operation · Severity warning · Category orm
Issuing single-row inserts/updates in a loop while a bulk API like insert_all/upsert_all exists produces needless round-trips. The work should collapse into one bulk call.
Incorrect
Section titled “Incorrect”products.each do |p| Item.create!(sku: p[:sku], price: p[:price])endCorrect
Section titled “Correct”rows = products.map { |p| { sku: p[:sku], price: p[:price] } }Item.insert_all(rows)Convert the per-row writes in the loop into a single bulk call such as insert_all/upsert_all.