# ActiveRecord loading veeeery slow

**URL:** <https://www.ruby-forum.com/t/activerecord-loading-veeeery-slow/192891>\
**Category:** IronRuby\
**Created:** [August 7, 2010, 8:21pm UTC](https://www.ruby-forum.com/t/activerecord-loading-veeeery-slow/192891 "2010-08-07T20:21:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michbukana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@michbukana](https://www.ruby-forum.com/u/michbukana)\
**Post date:** [August 7, 2010, 8:21pm UTC](https://www.ruby-forum.com/t/activerecord-loading-veeeery-slow/192891/1 "2010-08-07T20:21:51Z")

</div>

Hi all,

I’m having a performance issue when loading activerecord:

## I’m timing it in this code

puts Time.now.to\_s + “rubygems”  
require ‘rubygems’  
puts Time.now.to\_s + “activerecord”  
require ‘active\_record’  
puts Time.now.to\_s + “activesupport”  
require ‘active\_support’  
#require ‘acts\_as\_list’  
puts Time.now.to\_s + “yaml”  
require ‘yaml’  
ActiveRecord::Base.establish\_connection(  
:adapter =\> ‘sqlserver’,  
:database =\> ‘db’,  
:username =\> ‘sa’,  
:password =\> ‘password’,  
:mode =\> ‘ADONET’,  
:host =\> “machine\instance”)  
puts Time.now.to\_s + ‘classes’  
… (loads all the classes

* * *

The results are:

Sat Aug 07 13:49:08 -0400 2010rubygems  
Sat Aug 07 13:49:09 -0400 2010activerecord  
WARNING: YAML.add\_builtin\_type is not implemented  
Sat Aug 07 13:49:22 -0400 2010activesupport  
Sat Aug 07 13:49:22 -0400 2010yaml  
Sat Aug 07 13:49:23 -0400 2010connection  
Sat Aug 07 13:49:43 -0400 2010classes

as you can see the time to load activerecord is 13 seconds,  
and the time to establish the connection is 20 seconds,

Once everything is established, the system really works fine  
regarding response time with the database.

Is there anything I could do to improve the startup speed with  
activerecord and activerecord-sqlserver-adapter standard gems?

Is there any relation with the YAML.add\_builtin\_type not implemented  
warning?

Thank you all in advance,

Eduardo B.

---

<div class="post-metadata">

**Author:** ![michbukana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@michbukana](https://www.ruby-forum.com/u/michbukana)\
**Post date:** [August 28, 2010, 4:34pm UTC](https://www.ruby-forum.com/t/activerecord-loading-veeeery-slow/192891/2 "2010-08-28T16:34:43Z")

</div>

Any Ideas?

Thank you in advance

Eduardo B.

---

<div class="post-metadata">

**Author:** ![michbukana](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4af34b/32.png) [@michbukana](https://www.ruby-forum.com/u/michbukana)\
**Post date:** [September 7, 2010, 5:00am UTC](https://www.ruby-forum.com/t/activerecord-loading-veeeery-slow/192891/3 "2010-09-07T05:00:46Z")

</div>

Hi all,

I finally figured out the problem (weird tough).

It happens to be that I was using also (from the calling top-level  
program)

the following call:

load\_assembly “Microsoft.Office.Interop.Excel”  
include Microsoft:🏢:Interop::Excel

## I don’t have the reason why this happened, but just by moving those calls to a place after the

## require ‘db\_lib.rb’

that called the (previously) slow “connect” call,  
the time went from 14 seconds to 1 second (or less)

My guess about the problem may be that by including the  
Microsoft:🏢:Interop::Excel  
the ironruby adds a huge quantity of objects to inspect  
for a “method\_missing” that works in the active\_record gem,  
specially in the establish\_connection method.

Could my guess be correct?

Regards to all!!!

and keep working with IronRuby, IT ROCKS!!!

Eduardo B.
