ActiveRecord and postgres lateral joins

299 views
Skip to first unread message

Christopher COCCHI-PERRIER

unread,
Nov 24, 2015, 11:17:49 AM11/24/15
to Ruby on Rails: Core
Hi,

Is there any way to use PostgreSQL LATERAL joins (http://www.postgresql.org/docs/9.3/static/queries-table-expressions.html#QUERIES-LATERAL) with `AR#eager_load` on associations, to achieve partial eager loading?

My situation is: I have 2 models groups and users link together with a has_many :trough models memberships. When I list the groups, I want to eager load only the membership of the current user if it exists. Using this postgres function is the best way I have come up with.

Any thoughts?
Reply all
Reply to author
Forward
0 new messages