Pay attention to the following details when creating MYSQL indexes:

Source: Internet
Author: User
Tags mysql index
Pay attention to the following points when creating a MYSQL index: the time to create an index is costly for you to enable the index cache when you like multiple conditions, if you are interested, you can refer to this article, which may help you

Pay attention to the following points when creating a MYSQL index: the time when the index is created/For like/For/enabling the index cache with multiple conditions/indexing, etc, if you are interested, you can refer to this article, which may help you

1. index creation time: it is worthwhile to create an index for a field in select, filter, and sort conditions.

2. For Fuzzy queries like '% XXX', normal indexes cannot be satisfied, and full-text indexes must be created.

3. if there are multiple conditions, such :"... where a = xxx and B = yyy ","... where a = xxx order by B ","... where a = xxx group by B ". A composite index is required. However, the composite index can only be used when the SQL statement meets the "leftmost prefix. In addition, composite indexes have some side effects. For example, the index size may be larger than the data because the composite indexes have many composite entries. Therefore, in practical applications, we need to customize it and use the slow query analysis tool for analysis.

4. Enable the index cache to directly search for indexes in the memory and no more disks are needed.

5. index creation is costly. When the update and delete statements are executed, the index update will take more time. You can use the mysqlreport to understand the percentage of select, update, delete, insert, and replace statements.

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.