Hi,

I'm running into a memory performance issue with Active Record
associations.
I'm tinkering with Redmine, a rails-based project management
application.  The central model in the application is 'Project' which
associates via has_many to model Issue.  One of the things you can do
with Projects is copy them.  In a nutshell, copy is implemented like
this (in class Project):
def copy(other_project)
  other_project.issues.each do |other_issue|
    self.issues << other_issue.copy
  end
  self.save
end

The problem is that issues are themselves complex objects, and for a
project with many issues (several thousand), self.issues grows to the
point of exhausting memory and swap on the box, effectively making a DOS
attack out of this function.  So the question is, is there an idiomatic
Active Record solution to this problem?  Perhaps committing and flushing
the association list every N adds?

Thanks in advance for any advice.
-- 
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to