I’m in the process of optimizing my SQL queries on my heroku server so I can speed things up on one particular request. Right now I’m mainly looking at condensing all the INSERT queries into the fewest queries as possible.
At some point in my code I have this:
jobs.each do |j|
Delayed::Job.enqueue j
end
I found out that every iteration sends a BEGIN, INSERT, COMMIT to the db. That jobs array can have from a few to a couple hundred objects in it. I have looked for a way to batch insert delayed jobs but couldn’t find anything. Any idea of how to achieve that?
I ended up enqueuing my
Userobject instead, which had ajobsattribute. So 1 insert instead ofjobs.lengthinserts.