Load all records for an association in Ecto
Lets say you get a collection of Posts with:
If you try to access the associated developer for one of these posts, you get an error:
The same is true for all posts in the collection, none of them have a loaded developer. You can load them one by one with:
But if you need to do this for each developer you'll get into an N+1 situation, making an additional trip to the database for each post.
Instead you can load all the developers at one time with:
Tweet