Please bear with me on this question.
I’m looking to create a relatively large MySQL database that I want to use to do some performance testing. I’m using Ubuntu 11.04 by the way.
I want to create about 6 tables, each with about 50 million records. Each table will have about 10 columns. The data would just be random data.
However, I’m not sure how I can go about doing this. Do I use PHP and loop INSERT queries (bound to timeout)? Or if that is inefficient, is there a way I can do this via some command line utility or shell script?
I’d really appreciate some guidance.
Thanks in advance.
Probably it is fastest to run multiple inserts in one query as:
I created a PHP script to do this. First I tried to construct a query that will hold 1 million inserts but it failed. Then I tried with 100 thousend and it failed again. 50 thousends don’t do it also. My nest try was with 10 000 and it works fine. I guess I am hitting the transfer limit from PHP to MySQL. Here is the code:
The result on my Win 7 dev machine are:
So for 1 mil inserts it took 5 and a half seconds. Then I ran it with this settings:
which is basically doing one insert per query. The results are:
Then I tried to create a file with one insert per query in it, as suggested by
@jancha. My code is slightly modified:The result is:
Same as executing the queries through PHP. So, probably the fastest way is to do multiple inserts in one query and shouldn’t be a problem to use PHP to do the work.