On Thursday, October 1, 2015 at 5:06:19 PM UTC-7, Chris Hanks wrote:
>
> If you are only returning a single record, there is no reason to eager
>> load, it wouldn't save you any queries.
>>
>
> Yes, when I mentioned a more complex set of associations, I was referring
> to something like Post.eager(comments: {user: :followers}).first. I
> eager-load associations because I plan on using them, but it's ignored and
> I get N+1 queries instead.
>
You can set :eager=>{:user=>:followers} on the comments association so
that loading the comments for a single post will eager load the users and
followers. You can also do this by using post.comments{|ds|
ds.eager(:user=>:followers)}, or using the tactical_eager_loading plugin.
> I'm not sure I understand the issue with #each, I was able to get this
> behavior in testing simply by patching single_record to call post_load.
> There might be something I'm missing, though.
>
Patching single_record to call post_load may work for eager, but it won't
work for eager_graph.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.