MySQL database optimization (i) the loop of data is added

Source: Internet
Author: User

These two days are doing code optimization. Requires 100,000, millions, or more of the data. This time obviously a piece of add is not realistic, and then use the loop to add the statement.

in the first step, we need to build a test database temp_mysql_datatesting when we do the loop addition .

Create DATABASE temp_mysql_datatesting;

The second step, open the Temp_mysql_datatesting database to create the data table Temp_mysql_data;

CREATE TABLE Temp_mysql_data
(
Id INT primary Key auto_increment,
Email varchar (+) NULL comment ' user mailbox ',
Emailconfirmed bit NOT NULL comment ' authentication mailbox ',
PhoneNumber varchar (+) NULL comment ' User phone ',
lastlogintime datetime NULL comment ' Last logon time ',
firstlogintime datetime NULL comment ' First logon time ',
createtime datetime NULL comment ' creation time '
) Comment ' test data sheet ';

The third step, after the condition is ready, starts to loop to add the statement;

Create PROCEDURE Proc_while_insert ()/  * creates a function */0   300000 do/* Add quantity */* add statement, last English semicolon; end * /  1  ; END while; END;

Execute the function first, then find the function, execute the function. function location,

MySQL database optimization (i) the loop of data is added

Related Article

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.