Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rails 3 associations eager load of associated classes significantly slows down development environment

#5920

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

Reported by Steve F · November 4th, 2010 @ 08:17 PM

State: new
Milestone: 3.x
Assigned to: Michael Koziarski Michael Koziarski
Importance: Low

Activity

  1. Michael Koziarski
    Michael Koziarski
    • 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

    November 8th, 2010 @ 08:03 PM

  2. Neeraj Singh
    Neeraj Singh

    I am not able to reproduce this error with Rails edge. Is it a Rails 3-0-stable issue?

    November 10th, 2010 @ 01:35 PM

  3. Steve F
  4. Cesario
    Cesario

    I think we could mark this bug as invalid as it's not reproducible anymore.

    February 12th, 2011 @ 11:51 AM