Slow-down when creating many records in the console

Hi there,

I have a script I run through console to populate my forum application
with random test data. It is supposed to create thousands of forum
posts with several comments per post. The method essentially looks
like this:

forum = Forums.create
2000.times do
forum.posts.create
end

I’ve found that it slows to a near halt after it adds a few hundred
messages. What is happening here? Is there something I can do to
keep the thing moving quickly?

Thanks,

Andrew

[email protected] wrote:

I’ve found that it slows to a near halt after it adds a few hundred
messages. What is happening here? Is there something I can do to
keep the thing moving quickly?

Perhaps

2000.times do |i|
forum.posts.create
GC.start if i % 100 == 99
end


We develop, watch us RoR, in numbers too big to ignore.

Can you be more specific as to what your code is doing? ‘essentially’
doesn’t help to debug as I can write a quick test to do what you
posted and it takes not time at all to insert 2000 records.

Chris