This project is archived and is in readonly mode.
Rails 3 associations eager load of associated classes significantly slows down development environment
Reported by Steve F | November 4th, 2010 @ 08:17 PM | in 3.x
In rails238 the associated classes were not loaded until an association method was called. I'm sure this was a performance improvement in production, but with a class like User that is associated with about 50 other models which have their own nested associations, this significantly slows down requests, since User is reloaded on every request. I'm wondering if we could create development environment only behavior to lazy load scopes and associations. My User model takes about 7seconds to load.
Here's how I repro'd the issue in both environments:
I created the following two models:
#user.rb
class User < ActiveRecord::Base
has_many :documents
end
#document.rb
raise "I'm loading"
class Document < ActiveRecord::Base
end
I opened up a console:
> User
RuntimeError: I'm loading ###in rails3 but not rails238
> User.new.documents
RuntimeError: I'm loading ###in rails 238
Comments and changes to this ticket
-
Michael Koziarski November 8th, 2010 @ 08:03 PM
- Milestone set to 3.x
- Assigned user set to Michael Koziarski
- Importance changed from to Low
Would be nice to look at this for 3.0.2
-
Neeraj Singh November 10th, 2010 @ 01:35 PM
I am not able to reproduce this error with Rails edge. Is it a Rails 3-0-stable issue?
-
Cesario February 12th, 2011 @ 11:51 AM
I think we could mark this bug as invalid as it's not reproducible anymore.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>