korma/Korma — pull request #136 by cap10morgan (2013-03-28 16:36:35+00:00)
Title: Add ability to eagerly fetch sub-entities with has-many rels

Currently Korma exhibits the N+1 query problem (as described here: http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations) when fetching entities in a has-many relationship. In other words, it fetches the parent entity (1 query) and then fetches each related entity with it's own query (N queries).

This adds a new `with-eager` function that behaves just like `with` except that it eagerly fetches the sub-entities in a has-many relationship by using just 1 additional query that includes all of the parent entity ID's in an "WHERE ... [fk] IN (?)" clause.