Understanding Rails Eager-Loading

24-Jun-2019 1608
Note: this is an article that I posted a few years ago on Medium. I'm reposting here as it's likely to be more useful to someone that way.If you're like me, nothing makes your eyes glaze over faster than a wet, steaming pile of machine-generated SQL. My aim was to write a Rails eager-loading guide that's heavy on motivation and light on log statements. Hopefully I can provide you with the explanation I never had.This post assumes that you understand model associations, are comfortable with JOINs, and are familiar with the N 1 query problem. If any of that sounds foreign, I recommend playing with plain SQL first (SELECT, JOIN, .
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle