# Slow performance in ruby 1.9.1

**URL:** <https://www.ruby-forum.com/t/slow-performance-in-ruby-1-9-1/159216>\
**Category:** Rails\
**Created:** [February 2, 2009, 1:44pm UTC](https://www.ruby-forum.com/t/slow-performance-in-ruby-1-9-1/159216 "2009-02-02T13:44:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@andreas](https://www.ruby-forum.com/u/andreas)\
**Post date:** [February 2, 2009, 1:44pm UTC](https://www.ruby-forum.com/t/slow-performance-in-ruby-1-9-1/159216/1 "2009-02-02T13:44:20Z")

</div>

I’m not sure what ActiveRecord support status is for ruby 1.9.1, so I  
apologize if this report is premature. By the way, I’m only using  
ActiveRecord here, not Rails.

I notice a 4x slow down in my program when I switch to 1.9.1. I’ve  
narrowed it down to this

# works fine

class fast \< ActiveRecord::Base  
end

# 4x slower (I need to do this in my program because I’m building

table from the arbitrary csv input)  
slow = Class.new ActiveRecord::Base

The slow.connection.execute and a few other methods are 10x slower in  
ruby 1.9.1 but are fine in ruby 1.8.7. Benchmarking method call from  
these 2 different ways of defining a class doesn’t reveal anything  
(speed is ,practically speaking, the same). Any body ran into this  
problem?

Thank you in advance.

I’m using:  
activerecord 2.2.2  
activesuport 2.2.2  
ar-extensions 0.8.0  
sqlite3-ruby 1.2.4  
on RedHat Linux 2.6.9

A sample code to demonstrate it is as follow:

require ‘ar-extensions’  
require ‘fastercsv’

ActiveRecord::Base.establish\_connection :database =\>  
‘:memory:’, :adapter =\> ‘sqlite3’  
ActiveRecord::Schema.define do  
create\_table ‘bubububu’ do |t|  
t.string :user, :machine, :command  
t.integer :duration, :pid  
t.datetime :time  
end  
end

data = FasterCSV.read ARGV[0]

# This is fine in ruby 1.8.7 and 1.9.1

#class Egg \< ActiveRecord::Base

# set\_table\_name “bubububu”

#end  
#Egg.import [:pid, :user, :time, :duration, :machine, :command],  
data, :validate =\> false

# This ‘import’ is fine in ruby 1.8.7 but 4x slow in 1.9.1

egg = Class.new ActiveRecord::Base do  
set\_table\_name “bubububu”  
end  
egg.import [:pid, :user, :time, :duration, :machine, :command],  
data, :validate =\> false
