I have a model (Parent) that has a has_many association with another
model (Child).  I read that there are performance issues (relating to
GC) with too many associations.  I was about to add more has_many
associations to the parent model to get child objects ordered by
different columns like so:

(Inside Parent model)
...
  has_many :child, :through => :childx, :order => "category_1, date_1
desc"
  has_many :child1, :through => :childx, :source => :child, :order =>
"updated_at desc"
  has_many :child2, :through => :childx, :source => :child, :order =>
"date_1 desc"
  has_many :child3, :through => :childx, :source => :child, :order =>
"name_1"
...

Is this going to make ruby hold on to this parent object and 4 child
object and use up a lot of memory?  (Does the parent model get all the
child records child, child1, child2 and child3 as soon as Parent.find
is called?  Or are they only really queried when I access, say,
parent.child1?)

Is it better to just do a Child.find with the parent_id inside the
controller?  Or would it use up as much memory as soon as I do
Child.find?

Thanks for any insights!

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to