Easy to Overlook Way to Break Eager Loading in Rails Apps
https://pawelurbanek.com/rails-eager-ordered
In theory, configuring eager loading to avoid N+1 issues is straightforward. Chaining includes method is usually enough to ensure that all the relations data is fetched efficiently. However, this rule breaks for some easy-to-overlook edge cases. In this blog post, I’ll describe how to eager load ActiveRecord relations using custom SQL ORDER BY sorting.
Post a comment