Avoiding N+1 queries with Ecto is easy using preload/3 but I frequenty find that I need to preload a subset of an association. It turns out that there is a little magic 2 element tuple syntax that supports this.
preload/3
I was working with implementing a closure tree for replies on a comments table the other day and needed a way to represent the “parent” comment for rendering on the front end.