[PHP] How do I enter a large amount of random data into MYSQL to test the statement performance?

Source: Internet
Author: User
I have an empty MYSQL database. How do I enter a large amount of random data into MYSQL to test the statement performance? You can skip PHP and directly use SQL to achieve better performance. target 0.5 million -- about 1 million. I have an empty MYSQL database. How do I enter a large amount of random data into MYSQL to test the statement performance?

You can skip PHP and directly use SQL to achieve better performance.

Target0.5 million -- 1 millionAbout this level.

Reply content:

I have an empty MYSQL database. How do I enter a large amount of random data into MYSQL to test the statement performance?

You can skip PHP and directly use SQL to achieve better performance.

Target0.5 million -- 1 millionAbout this level.

Try generatedata, which is open-source. You can build a local site to generate the desired data.
There are many other similar items. Refer to this list:

Http://databene.org/databene-benerator/similar-products.html

Php generates an SQL file for import ~

INSERT INTO `table` ( `field1`, `field2` ) VALUES( 1,1 ),( 2,2 )....( 5000,5000 );

I accidentally discovered a pure SQL method!

BENCHMARK (loop_count, expression)

The stored procedure is much faster than PHP.

Declare I int default 0;
While I & lt; 100000000 do
Insert into users (value) values (RAND ());
Set I = I + 1;
End while;
This is not the case for an SQL statement.

I have asked professional DBAs before.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.