How to create 10000 pseudo data for Testing in RoR

I want to test performance of project.
So i want make 10000 record of table for testing.
I don't know how to ganerate record.
Who can help me? Thanks.

Depends on what you're trying to test.

If it's a single table and the values in the database don't matter, you can
just add a [0..10000].each loop in seed.rb

Or copy production data

Or use a sql script to load your database

Or one of these

Thanks Greg Akins
I'm using MongoDB and in Mongodb has some table as:
And tables have ralationship(user relationship with photos..) ....
Could you give me some advice for this problem?Thanks

You can add data via Rails models, like

User.create({ <your attributes for user goes there })

Just use rails code inside seed.rb to generate whatever you like and then run rake task which is something like rake db:seed

As far as cloning development DB into test DB, check out

Yes ,Thanks Gintautas
If I want create 1000000(1 million) pseudo data,i can this way for it?
And i hear a gem with called "faker"
can i using this gem for solve my problem ( create 1000000 pseudo data)?
Thanks very much

Maybe, I don’t know :slight_smile: you just got to investigate stuff, that’s part of learning something new process :slight_smile:

Though just simple db:seed and then exporting development DB and importing it into test DB should do the trick.


Faker might be overkill… or might not. Try both approaches and let us know which works best.

If you have ActiveRecord model defined (say User.rb)

Then just include this in the db/seed.rb

[0…1000000].each do |i|

User.create(:name => “name#{i}”, etc…)


A problem with this approach is distribution of data. If you need the names to be distributed across an alphanumeric range (to mimic real world data) then you might want to modify the mechanism for creating the User.

Thank Gintautas,Greg Akins very much
I will do with instruction of you.
Thank you vey much again!!!

haxuan lac wrote in post #1104574:

I want to test performance of project.
So i want make 10000 record of table for testing.
I don't know how to ganerate record.
Who can help me? Thanks.

Look at rails cast #179.
this has a tutorial on using seed.rub to create test data.

Props, Greg! I’m impressed with your response. I saw the question, and these kinds of questions really bother me because they lack specificity. I was thinking maybe we should have a noob web form app that could help them build their questions properly for submitting, by asking THEM lots of questions. :slight_smile: Then we could just point them to it, and say hey, do this! :slight_smile:

But yeah, “more information please, as much as possible” is such a common thing to say.


Maybe we should also have a big ass sign on-top of it for people who make worthless comments, all it needs to say is “don’t make worthless comments.” And yes, I realize the irony.

I tried create 10000 pseudo by Faker but it's very slow.
I fake 1000 record about 20 minutes.
And 10000 record take me 2-3 hours.
please give me some advice about this time I had done with fake pseudo
data(1000 and 10000 pseudo).

I think it has been suggested several times that you use rake db:seed
with seed.rb. Have you investigated that route?


anytime you use the ORM to insert 10_000 records it’s going to be slow as it does them one at a time. i suggest gong the direct sql route in this case.

Write a Ruby script to do it, invoke it via a rake task.

One approach may be to build the data as a large csv. Which you could do from ruby if you wished and you can then keep as a file. Then either import directly to the db with sql or workbench etc. or if you want to stay ruby, load the csv and use ar_extension import to dump the data into the db.