Mysql Insert Declaration Optimization

Source: Internet
Author: User
Tags bulk insert mysql insert

1) Assume that you are inserting very many rows from the same customer at the same time, using the INSERT statement for multiple value tables.

This is faster than using separate INSERT statements (several times in some cases).
Insert into test values (1,3), (1,4) ...

2) Suppose you insert very many rows from different customers. Can get higher speed by using the Insert delayed statement.

The implication of delayed is that the INSERT statement runs immediately, in fact the data is placed in the queue of memory and is not actually written to disk. This is much faster than inserting each statement, and low_priority the opposite, inserting the table after all other users have read and write it.

3) Place index files and data files on separate disks (using the options in the Build table).



4) Assume a bulk insert. The ability to add the value of the bulk_insert_buffer_size variable to raise the speed, but. This can only be used on MyISAM tables.

5) When loading a table from a text file, use load DATA INFILE. This is usually 20 times times faster than using very many INSERT statements.

6) Use the Replace statement instead of INSERT, depending on the application.

7) Ignore duplicate records according to different application cases Ignorekeyword.

Mysql Insert Declaration Optimization

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.