Hai.. Whether ruby on rails is eager loading or lazy loading??? I think while using association in model its getting eager loading.. can any one explain more??? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 3 Apr 2008, at 14:57, Selvaraj Subbaian wrote:> > Hai.. > > Whether ruby on rails is eager loading or lazy loading??? > > I think while using association in model its getting eager loading..Assuming I do bob = Person.find(124) and then do something with bob.orders, then the association is lazy loaded, it''s not loaded until you touch it. You can also eager load: bob = Person.find(124, :include => ''orders'') Fred
Thanks...I got it... Frederick Cheung wrote:> On 3 Apr 2008, at 14:57, Selvaraj Subbaian wrote: > >> >> Hai.. >> >> Whether ruby on rails is eager loading or lazy loading??? >> >> I think while using association in model its getting eager loading.. > > Assuming I do bob = Person.find(124) and then do something with > bob.orders, then the association is lazy loaded, it''s not loaded until > you touch it. You can also eager load: bob = Person.find(124, :include > => ''orders'') > > Fred-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Frederick Cheung wrote:>> Assuming I do bob = Person.find(124) and then do something with >> bob.orders, then the association is lazy loaded, it''s not loaded until >> you touch it. You can also eager load: bob = Person.find(124, :include >> => ''orders'')How do you use :include to add a column that must appear in the :conditions, _without_ eagerloading everything in that column''s table? When we were tuning and we hit that one, we had to drop :include back to an old-fashioned :joins, which is really irritating! A :lazy => true directive would have fixed it... -- Phlip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 22 Apr 2008, at 14:01, Phlip wrote:> >> Frederick Cheung wrote: > >>> Assuming I do bob = Person.find(124) and then do something with >>> bob.orders, then the association is lazy loaded, it''s not loaded >>> until >>> you touch it. You can also eager load: bob = >>> Person.find(124, :include >>> => ''orders'') > > How do you use :include to add a column that must appear in > the :conditions, > _without_ eagerloading everything in that column''s table? > > When we were tuning and we hit that one, we had to drop :include > back to an > old-fashioned :joins, which is really irritating! >You can do that with joins these days (:joins => :orders) Fred> A :lazy => true directive would have fixed it... > > -- > Phlip > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---