[PHP] How to fill a lot of random data into MYSQL to test the statement performance?

Source: Internet
Author: User
Have an empty MySQL database, how to fill a lot of random data into MySQL to test the statement performance?

Everyone brainstorming, can skip PHP directly with SQL to achieve better.

Target 500,000--1 million this level around.

Reply content:

Have an empty MySQL database, how to fill a lot of random data into MySQL to test the statement performance?

Everyone brainstorming, can skip PHP directly with SQL to achieve better.

Target 500,000--1 million this level around.

Try Generatedata This is open source, you can build a site locally, generate the data you want.
There are many other similar, refer to this list:

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

PHP generates a SQL file import ~

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

Accidentally found a pure SQL method, Quack!

BENCHMARK (loop_count,expression)

Try the stored procedure much faster than PHP.

declare i int default 0;
While I < 100000000 do
Insert into users (value) values (RAND ());
Set i = i + 1;
End while;
A SQL is not the right thing to do.

I've asked a professional DBA 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.