Why this matters
Eliminates N+1 updates and speeds up batch changes.
When callbacks/validations are not required, prefer a single UPDATE statement via update_all over iterating records and calling update.
Eliminates N+1 updates and speeds up batch changes.
Side-by-side examples engineers can pattern-match during review.
User.where(active: false).each { |u| u.update(active: true) }User.where(active: false).update_all(active: true)each { |r| r.update(...) }Model.where(...).update_all(...)From the same buckets as this rule.
Review SQL/database migrations for operations that can lock large tables or cause downtime. Examples: creating indexes without CONCURRENTLY (Postgres), ALTER COLUMN TYPE on big tables, adding NOT NULL without backfill, long-running updates without batching. Require an online migration strategy (CONCURRENTLY, backfill in batches, dual-write/expand-contract) and a rollback plan.