The problem is because of following line in
associations.rb:#construct_associations :
collection.target.push(association) unless
collection.target.include?(association)
This basically compares every processed object with the new object, to
see if it hasn't been instansiated already.
For testing, I created two simple models :
class Person < ActiveRecord::Base
has_many :items
end
class Item < ActiveRecord::Base
belongs_to :person
end
I don't have time to test this but have you tried to eager load several
has_many associations at once (so there are M*N result rows)
and compare the memory consumption of the new approach with the old one?
The problem is because of following line in
associations.rb:#construct_associations :
collection.target.push(association) unless
collection.target.include?(association)
This basically compares every processed object with the new object, to
see if it hasn't been instansiated already.
The problem is because of following line in
associations.rb:#construct_associations :
collection.target.push(association) unless
collection.target.include?(association)
This basically compares every processed object with the new
object, to
see if it hasn't been instansiated already.
That was rather fugly Array#uniq! basically builds up a hash and
then collects the things in the hash, so it should be pretty similar.
The one possible area of concern (as pointed out by tarmo) is memory
consumption with a large result set.