You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cfad0ed
Browse filesBrowse the repository at this point in the historyBrowse files
Mohammad alkhassawneh
authored and
Mohammad alkhassawneh
committed
Fix superfluous SELECT when scheduling/dispatching a single job
When a single job is enqueued, each Execution subclass fires a SELECT
on solid_queue_jobs before INSERT. This happens because:
1. assumes_attributes_from_job sets a before_create callback that calls
job.send(attribute) for each attribute to copy from the job record.
2. Since create_or_find_by!(job_id: id) only sets the job_id foreign key,
the job association isn't loaded — so accessing it triggers a SELECT.
The bulk path (enqueue_all) already avoids this by using insert_all,
which bypasses callbacks entirely.
Fix: pass job: self via the create_or_find_by! block so the association
is already loaded in memory when both the before_create callback and the
belongs_to validation run. No DB round-trip needed.
Applied to all three single-job dispatch paths: schedule (ScheduledExecution),
ready (ReadyExecution), and block (BlockedExecution).
0 commit comments