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:

class User < ActiveRecord::Base
  has_many :documents

raise "I'm loading"
class Document < ActiveRecord::Base

I opened up a console:

> User
RuntimeError: I'm loading ###in rails3 but not rails238

> 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=""></a>