# Model caching reloading in development is making things slow

**URL:** <https://www.ruby-forum.com/t/model-caching-reloading-in-development-is-making-things-slow/119124>\
**Category:** Rails\
**Created:** [November 3, 2007, 12:34pm UTC](https://www.ruby-forum.com/t/model-caching-reloading-in-development-is-making-things-slow/119124 "2007-11-03T12:34:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [November 3, 2007, 12:34pm UTC](https://www.ruby-forum.com/t/model-caching-reloading-in-development-is-making-things-slow/119124/1 "2007-11-03T12:34:11Z")

</div>

In my development env, I was working on a module in my rails app. This  
action was taking approximately 7 seconds to complete. I was adding in  
tracing marks to figure out where which actions were taking the longest.  
All of a sudden, almost literally out of nowhere, the action starts  
taking 15-19 seconds to complete.

I investigated this issue by Benchmarking virtually the entire scope of  
AR save and callbacks.

It turns out that in my callbacks I reference other AR model classes.  
And apparently because rails reloads model classes on each action in  
development, it takes about .25 seconds just to run g = Photo. Normally  
this action should take 0.0 seconds.

Im sure I was in development the entire time because prod and test don’t  
work on my dev workstation.

This is very odd. The behavior of this really was out of nowhere  
because all I was doing was adding Benchmark.realtime to do some  
harmless benchmarking, and now I can’t get it so that AR models dont  
have to reload each time a AR model is called, or atleast not take .25  
seconds each time it is called.

How can I get my rails app to working so it doesnt take so long just to  
call “Photo” or “Book” AR model.

---

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [November 3, 2007, 3:47pm UTC](https://www.ruby-forum.com/t/model-caching-reloading-in-development-is-making-things-slow/119124/2 "2007-11-03T15:47:36Z")

</div>

> This is very odd. The behavior of this really was out of nowhere  
> because all I was doing was adding Benchmark.realtime to do some  
> harmless benchmarking, and now I can’t get it so that AR models dont  
> have to reload each time a AR model is called, or atleast not take .25  
> seconds each time it is called.
> 
> How can I get my rails app to working so it doesnt take so long just  
> to  
> call “Photo” or “Book” AR model.

Change config.cache\_classes in development.rb

Fred
