Analysis of five types of Mysql index invalidation _mysql

Source: Internet
Author: User
Tags mysql index

Indexes do not always take effect, such as the following situations, which will result in index invalidation:

If there is an or in the condition, it will not be used even if there is a conditional index (which is why the use of or is as little as possible)

  

Note: If you want to use or, and you want the index to take effect, you can only index each column in the OR condition

  2. Index is not used for multiple-column indexes, not the first part used

  3.like query starts with%

  4. If the column type is a string, make sure that the data is quoted in quotes in the condition, otherwise the index is not used

  

  5. If the MySQL estimate uses a full table scan to be faster than using the index, the index is not used

In addition, view the usage of the index

Show status like ' handler_read% ';
We can note that:
Handler_read_key: The higher the value the better, the higher the number of times that the index query is used Handler_read_rnd_next: The higher the value, the less efficient the query

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.