Under what circumstances will indexes become invalid ?, When the index is invalid? _ PHP Tutorial

Source: Internet
Author: User
Under what circumstances will indexes become invalid ?, When the index is invalid ?. Under what circumstances will indexes become invalid ?, When the index is invalid? The index does not always take effect. for example, in the following situations, the index will become invalid: Note: If you want to use or, in which cases do you want to invalidate the index ?, When the index is invalid?

The index does not always take effect, for exampleIndex failure may occur in the following situations::

Note: to use or and make the index take effect, you must add an index to each column in the or condition.

2. if multiple-column indexes are not the first part, they are not used.

3. like queries start with %

4. if the column type is string, you must reference the data in quotation marks in the condition. otherwise, no index is used.

5. if mysql estimates that using full table scan is faster than using indexes, no indexes will be used.

In addition, view the index usage

Show status like 'handler _ read % ';
Note:
Handler_read_key: the higher the value, the better. the higher the value indicates the number of handler_read_rnd_next queries using the index. the higher the value, the less efficient the query.

Why ?, When the index is invalid? The index does not always take effect, for example, the following situations will lead to index failure: Note: to use or, you want to make...

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.