MySQL Database Performance Tuning summary accumulation

Source: Internet
Author: User

MySQL database tuning can be divided into four chunks

0 Architecture Tuning

---Sub-table based on business reading and writing

---master-slave read-write separation

1 Tuning of the configuration

Set Cache Size---open cache query

---Maximum number of connections settings

---database engine configuration myisam (read operation, query fast) Innodb (write operation, main library, support transaction, security) engine configuration

---log configuration

2 Table Structure Tuning

----Establish an appropriate index (primary key index, unique index, normal index, full-text index MyISAM used to retrieve text) EXPLAIN Select command there can often get some help knowing what needs to be indexed (Pros: Query fast disadvantage: Occupy space, update SQL Slow)

---Try to add an ID column to each table, except for the associated table

---table, vertical split, column is too long, split into fixed-length tables and fixed-length table-length queries are faster, provided that other tables after the library are not frequently join. Otherwise less efficient.

3 Tuning for SQL

---Avoid full fuzzy query%like%, it will invalidate the index.

---Avoid using SQL functions directly in SQL, SQL functions invalidate cached queries and replace them with variables.

---Large-volume operations are more efficient with limit batching (avoid locking the full table), and with limit 1, it is more efficient to know that only 1 queries are taken out of the data.

---is NOT null <>! =, invalidates the index.

---for some fixed-value columns, it is more efficient to use enums instead of varchar as much as possible.

---Avoid meaningless full-table scans count (*)

MySQL Database Performance Tuning summary accumulation

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.