Try not to loop through associations inside jobs - Andy Croll

One of the downsides of using Ruby to interact with your database, rather than SQL directly, is that it’s easy to accidentally give yourself performance headaches via running multiple very similar queries. Although the advantages of using Active Record (or something similar) are generally worth it!This is typically referred to as an N 1 problem. They occur most often seen when you display an Active Record object in a view and show all of the associated records that belong_to to it. When lots of records do need to be loaded or saved to the database you can putting this heavier database work in asynchronous jobs.
Try not to loop through associations inside jobs - Andy Croll #ruby #rubydeveloper #rubyonrails https://rubyonrails.ba/single/try-not-to-loop-through-associations-inside-jobs-andy-croll

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles