MySQL DML operation suggestions

Source: Internet
Author: User

For MySQL DML operations, we recommend that you (I) INSERT large data volumes (I) replace a single row with multiple rows:

insert into t values (),(),(),...

 

(2)
 LOAD DATA INFILE ... INTO TABLE t

 

(3) Write a temporary table and INSERT... SELECT (4) cancel the index and constraints, after the data is loaded, specify the DELAYED attribute when re-constructing the explain INSERT statement. Before InnoDB can be divided into multiple transactions and committed in batches (ii) large data volume UPDATE, you should also disable the index and related constraint ① unique SELECT field, change Field ② write the result set to the temporary table ③ create a composite index for the temporary table ④ each record of the temporary cyclic table ⑤ update the change field of the target table based on the unique field of the temporary table (3) Large data Volume DELETE ① partitioned table ② first obtain the unique identifier of the data to be deleted to the temporary table, and the cursor cyclically deletes data in batches.

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.