This project is archived and is in readonly mode.

#5920 new
Steve F

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

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>

Pages