# Loading 3000 models to Ruby on Rails. Performances?

**URL:** <https://www.ruby-forum.com/t/loading-3000-models-to-ruby-on-rails-performances/186056>\
**Category:** Rails\
**Created:** [March 30, 2010, 11:25pm UTC](https://www.ruby-forum.com/t/loading-3000-models-to-ruby-on-rails-performances/186056 "2010-03-30T23:25:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [March 30, 2010, 11:25pm UTC](https://www.ruby-forum.com/t/loading-3000-models-to-ruby-on-rails-performances/186056/1 "2010-03-30T23:25:59Z")

</div>

Hi,

I just wandering. If I autoload 3000 Ruby on Rails classes, will it need  
more computer memory? is more rails classes loaded, more memory needed?  
will it cause performances problems?

Thanks,  
John

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [March 30, 2010, 11:44pm UTC](https://www.ruby-forum.com/t/loading-3000-models-to-ruby-on-rails-performances/186056/2 "2010-03-30T23:44:48Z")

</div>

Hi John,

More classes and instances will use more memory. Many websites uses  
Rails with these 3000+ classes in production, so that’s not really a  
problem.

What exactly is your question? You can disable parts of the Rails  
framework in your environment.rb, but that won’t make a big  
difference.

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [March 31, 2010, 1:36am UTC](https://www.ruby-forum.com/t/loading-3000-models-to-ruby-on-rails-performances/186056/3 "2010-03-31T01:36:36Z")

</div>

You may really want to look at a NoSQL option, like MongoDB.

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [March 31, 2010, 12:24am UTC](https://www.ruby-forum.com/t/loading-3000-models-to-ruby-on-rails-performances/186056/4 "2010-03-31T00:24:46Z")

</div>

pl wrote:

> Hi John,
> 
> More classes and instances will use more memory. Many websites uses  
> Rails with these 3000+ classes in production, so that’s not really a  
> problem.
> 
> What exactly is your question? You can disable parts of the Rails  
> framework in your environment.rb, but that won’t make a big  
> difference.

Hi Pl,

Great to know many website use more than 3000+ classes.

Basically,

1. I will have huge numbers of tables and each one of them have totally  
different columns. This because I want user to be able to upload theirs  
own data/tables.  
So, in this case, it can be even 20000+ classes.

2. For each tables, I will have model class that will access that table.

3. By having these no 1 and 2 requirement, I will need to load “model  
classes” dynamically whenever a user import their own table without  
restarting rails. So that’s why I am looking into autoload feature. But  
seems like autoload only loading it from file. It will not load based on  
“string that contain model class”

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [March 31, 2010, 1:43am UTC](https://www.ruby-forum.com/t/loading-3000-models-to-ruby-on-rails-performances/186056/5 "2010-03-31T01:43:01Z")

</div>

John John wrote:

> E. Litwin wrote:
> 
> > You may really want to look at a NoSQL option, like MongoDB.
> 
> Yes, I indeed using NoSQL. Even with NoSQL, you still need Model Class  
> to save and retrieve data. :).

oh yeah, I think I found the solution of using Object::const\_set

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [March 31, 2010, 1:40am UTC](https://www.ruby-forum.com/t/loading-3000-models-to-ruby-on-rails-performances/186056/6 "2010-03-31T01:40:27Z")

</div>

E. Litwin wrote:

> You may really want to look at a NoSQL option, like MongoDB.

Yes, I indeed using NoSQL. Even with NoSQL, you still need Model Class  
to save and retrieve data. :).

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [March 31, 2010, 1:52am UTC](https://www.ruby-forum.com/t/loading-3000-models-to-ruby-on-rails-performances/186056/7 "2010-03-31T01:52:48Z")

</div>

no need to answer find the answer using eval

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [March 31, 2010, 1:45am UTC](https://www.ruby-forum.com/t/loading-3000-models-to-ruby-on-rails-performances/186056/8 "2010-03-31T01:45:25Z")

</div>

The next question is.  
---------- is it possible to convert this -----  
Object::const\_set(name.intern, Class::new do  
def write  
puts “TEST”  
end  
end  
)

--------- convert above to -----------------  
string\_test = ’ def write  
puts “TEST”  
end’  
Object::const\_set(name.intern, Class::new do  
string\_test  
end  
)

-------- is that possible?
