# Ruby1.9 and ActiveRecord

**URL:** <https://www.ruby-forum.com/t/ruby1-9-and-activerecord/166231>\
**Category:** Ruby\
**Created:** [April 23, 2009, 12:43am UTC](https://www.ruby-forum.com/t/ruby1-9-and-activerecord/166231 "2009-04-23T00:43:46Z")\
**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:** [April 23, 2009, 12:43am UTC](https://www.ruby-forum.com/t/ruby1-9-and-activerecord/166231/1 "2009-04-23T00:43:46Z")

</div>

I wanted to switch my app from ruby 1.8 to 1.9 but I notice  
ar-extensions’ ActiveRecord#import takes longer. The code to demonstrate  
it is attached. There is no significant time difference in both  
variations in ruby 1.8 (I used fastercsv for 1.8). It looks like 1.9  
issue, but first of all I’d appreciate if somebody can confirm this  
behavior

Thanks in advance.  
-andre

------ test\_ar.rb -----  
require ‘ar-extensions’  
require ‘csv’

ActiveRecord::Base.establish\_connection :adapter =\> ‘sqlite3’, :dbfile  
=\> ‘:memory:’  
ActiveRecord::Schema.define do  
create\_table ‘jobs’ do |t|  
t.column :xid, :integer  
t.column :user, :string  
t.column :time, :time  
t.column :duration, :integer  
t.column :machine, :string  
t.column :command, :string  
end  
end

# This one is slow. Notice local variable “job”

job = Class.new ActiveRecord::Base do  
set\_table\_name ‘jobs’  
end

# This one is fast. Notice constant “Job”

#Job = Class.new ActiveRecord::Base do

# set\_table\_name ‘jobs’

#end  
#job = Job

data = CSV.read “data.csv”, :headers =\> false  
job.import %w{ xid user time duration machine command }, data,  
:validate =\> false

# Fast one (with constant Job)

[lwe1:fx] time ruby19 test\_ar.rb  
– create\_table(“jobs”)  
-\> 0.0701s  
6.349u 0.231s 0:06.97 94.2% 0+0k 0+0io 0pf+0w

# Slow one (with local variable job)

[lwe1:fx] time ruby19 test\_ar.rb  
– create\_table(“jobs”)  
-\> 0.0647s  
27.533u 0.270s 0:28.08 99.0% 0+0k 0+0io 0pf+0w
