Making TENS test tables in MySQL database

Source: Internet
Author: User

Objective:

Recently prepared to learn more about MySQL, including the characteristics of various engines, performance optimization, sub-table sub-library and so on. In order to facilitate the performance of testing, table and other work, you need to first build a larger data table. I'm going to build a tens of millions of user tables here first.


Steps: 1 Creating a data table (MyISAM storage insertion speed is much faster than InnoDB mode )

Data table Description

Data Volume:10 million
field type:
ID: Ref.
uname: User name
Ucreatetime: Creation Time
Age: Ages


2 Creating an Insert data stored procedure

Delimiter $ $SET autocommit = 0$ $create  procedure test1 () Begindeclare v_cnt Decimal (Ten)  default 0;dd: Loop           I Nsert into  USERTB values (null, ' User 1 ', ' 2010-01-01 00:00:00 ', '), (null, ' User 2 ', ' 2010-01-01 00:00:00 ', '), (null, ' User 3 ', ' 2010-01-01 00:00:00 ', ' (null, ' User 4 ', ' 2010-01-01 00:00:00 ', '), (null, ' User 5 ', ' 2011-01-01 00:00:00 ', '), (NULL, ' User 6 ', ' 2011-01-01 00:00:00 ', ' (null, ' User 7 ', ' 2011-01-01 00:00:00 ', '), (null, ' User 8 ', ' 2012-01-01 00:00:00 ', '), (null , ' User 9 ', ' 2012-01-01 00:00:00 ', ' (null, ' user 0 ', ' 2012-01-01 00:00:00 ', ');                  commit;                    Set v_cnt = v_cnt+10;                           If  v_cnt = 10000000 then leave DD;                          End If;         End loop DD; end;$ $delimiter;

3 Executing stored procedures

Call Test1;

Time consuming: It takes only 95 seconds to execute with I5 's Notebook

4 Modify the engineer as needed (non-essential steps if no conversion is required)

ALTER TABLE USERTB ENGINE=INNODB;
Time consuming: It takes only 200 seconds to execute with I5 's Notebook


Making TENS test tables in MySQL database

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.