Hi, I''m using Rails 2.2 with SQlite. Eager loading doesn''t seem to be working, instead of a join two selects are executed: class Category < ActiveRecord::Base has_many :tools end class Tool < ActiveRecord::Base belongs_to :category end>> Tool.find(:all, :include => :category)Tool Load (53.1ms) SELECT * FROM "tools" Category Load (6.0ms) SELECT * FROM "categories" WHERE ("categories"."id" = 1)>> Category.find(:all, :include => :tools)Category Load (1.9ms) SELECT * FROM "categories" Tool Load (8.8ms) SELECT "tools".* FROM "tools" WHERE ("tools".category_id IN (1,2,3,4,5,6,7,8,9)) Am I missing something? Thanks, -- Adriano --~--~---------~--~----~------------~-------~--~----~ 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 Dec 23, 5:27 pm, Adriano <adri...-S20CnuFijpQ39yzSjRtAkw@public.gmane.org> wrote:> Am I missing something? >That''s how it works in rails 2.1 and above Fred> Thanks, > > -- > Adriano--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 23, 4:00 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 23, 5:27 pm, Adriano <adri...-S20CnuFijpQ39yzSjRtAkw@public.gmane.org> wrote: > > > Am I missing something? > > That''s how it works in rails 2.1 and aboveAh, thanks. I guess I didn''t read the release notes carefully (I''m curious to know the rationale behind the change). -- Adriano --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 23 Dec 2008, at 18:09, Adriano wrote:> > On Dec 23, 4:00 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On Dec 23, 5:27 pm, Adriano <adri...-S20CnuFijpQ39yzSjRtAkw@public.gmane.org> wrote: >> >>> Am I missing something? >> >> That''s how it works in rails 2.1 and above > > Ah, thanks. > > I guess I didn''t read the release notes carefully (I''m curious to know > the rationale behind the change). >Generally, small simpler querys often end up being easier to handle. join based include was also slow if you included two has_many associations at the same time (because the result set would effectively have the product of those two associations). Code is quite a bit simpler too. Fred> -- > Adriano > > >--~--~---------~--~----~------------~-------~--~----~ 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 Dec 23, 2008, at 1:22 PM, Frederick Cheung wrote:> On 23 Dec 2008, at 18:09, Adriano wrote: >> On Dec 23, 4:00 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >>> On Dec 23, 5:27 pm, Adriano <adri...-S20CnuFijpQ39yzSjRtAkw@public.gmane.org> wrote: >>> >>>> Am I missing something? >>> >>> That''s how it works in rails 2.1 and above >> >> Ah, thanks. >> >> I guess I didn''t read the release notes carefully (I''m curious to >> know >> the rationale behind the change). >> > > Generally, small simpler querys often end up being easier to handle. > join based include was also slow if you included two has_many > associations at the same time (because the result set would > effectively have the product of those two associations). Code is quite > a bit simpler too. > > Fred >> -- >> Adriano >> >>>Because when you get up to an eager load of something like: find(:all, :include => { :address => [:state, :country], :school => { :admin_contact => { :address => [:state, :country]}}}, :conditions => { :type => ''ReceivingAccount'', :aasm_state => ''in_production'' }) (yes, this is real) The resulting set of queries is much more efficient that the huge single-query equivalent. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---