Common optimization knowledge of MySQL

Source: Internet
Author: User

Index type: Primary key index, unique index, federated Index, normal index, full-text index

1. After indexing on a column, if you are using a like query, the percent semicolon is not indexed on the left. such as select a from t where BB like '%hehe '; in this case, BB has no index to use.

2. If the or keyword is used, there is a field on either side of the left or right without an index. Like select a from t where B=1 or c=2; In this case, if B or C has an index, it is not indexed.

3. When the group by is sorted by default, the sorting is very performance, and if not necessary, an order by null can be added. This is better. By the way, the order by frequently ordered field plus index.

(You can view it by Explai SQL without using an index on it.) )

4. A field of data type, can meet business requirements, the smaller the better. For example, the use of enums is much better than varchar.

5. In financial systems or money, decimals are saved using decimal, which is best used.

6. If you know that you want to find one in business, it's best to add a limit of 1 to SQL.

MyISAM the storage engine, the index is. Myi file: Data exists. MyD file ... frm is a table structure file.

the difference between MyISAM and InnoDB can be found in detail: http://www.oschina.net/question/17_4248

MyISAM Deleting the Delete does not really remove the database file, it needs to execute optimize table to clear the fragment. Table-level locks.

The data that exists in the INNODB will be in a file ibdata1 outside. In the MyD file. It's not like MyISAM. Support transactions. Foreign keys are supported. General row-level locks.

Common optimization knowledge of MySQL

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.