Eager loading is a way to load objects of a certain class and a number of named associations in the same request.
When you load records from the database and also want to access the associated objects for each of these records, it’s a good idea to make use of eager loading. Eager loading reduces the amount of queries made to the database and therefore increases performance.
This is one of the easiest ways of to prevent the dreaded 1+N problem in which fetching 100 posts that each need to display their author triggers 101 database queries. Through the use of eager loading, the 101 queries can be reduced to 2.
# Rails 2
Blogpost.all(:include => :comments)
# Rails 3
Blogpost.includes(:comments).all
# Entity Framework
Blogpost.Include(bp => bp.Comments);