migration

hello All

I am trying to create a table using rails migrations. after creating the table i want to move data from one table to newly created table. everything seems to be working fine.. only issue is speed of moving data.

Abc.find(:all).each do |a|

      xyz.new do |x|               xyz.id = a.id              xyz.save       end end

i have over 200,000 rows in my table.. and it is very slow...

is there a better way to move data quickly?

Please advice..

Cheers

Ajit

hello All

I am trying to create a table using rails migrations. after creating the table i want to move data from one table to newly created table. everything seems to be working fine.. only issue is speed of moving data.

Abc.find(:all).each do |a|

     xyz.new do |x|              xyz.id = a.id             xyz.save      end end

i have over 200,000 rows in my table.. and it is very slow...

Ouch. I would probably drop down to some raw sql (good old insert into
x values(...) (select ... from)) It might be slightly quicker if you : - didn't load all the the abcs in one go - did each chunk of abcs in a transaction (cuts down on how often the
database has to flush to disk)

Fred