Mysql example Mysql

Source: Internet
Author: User
Mysql Note 1 bitsCN.com

Mysql Note 1

1. disable the query cache. query_cache_size = 0.

2. Innodb tables are saved in the order of primary keys. Therefore, sorting imported data in the order of primary keys can effectively improve the efficiency of data import.

3. set innodb_flush_log_at_trx_commit to 2 or 0.

The default value 1 indicates that logs need to be written to the hard disk (flush) for each transaction commit or non-transactional command. this is time-consuming. Set to 2 is applicable to many applications, especially the conversion from the MyISAM table. it means writing data to the system cache instead of writing data to the hard disk.

Logs are flushed to the hard disk every second, so you will not lose updates that exceed 1-2 seconds. Setting 0 is faster, but the security is poor. even if MySQL fails, the transaction data may be lost. Value 2 can only lose data when the entire operating system is down.

4. run SET UNIQUE_CHECKS = 0 before the data is imported, disable the uniqueness check, and run SET UNIQUE_CHECKS = 1 after the import to restore the uniqueness check, which improves the import efficiency.

5. if the application uses the automatic submission method, we recommend that you execute set autocommit = 0 before import, disable automatic submission, and execute set autocommit = 1 after import. enable automatic submission, it can also improve the import efficiency.

6. store index files and data files on different disks (using the options in table creation ).

7. disable the foreign key Check. SET foreign_key_checks = 0;

BitsCN.com

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.