Mysql index is invalid and index effective detailed introduction _mysql

Source: Internet
Author: User
1, where the query conditions in the sentence is not equal to the number (where column!= ...) ), MySQL will not be able to use the index
2. Similarly, if a function is used in the query condition of the WHERE clause (for example, where day (column) = ...). ), MySQL will not be able to use the index
3, in the join operation (need to extract data from multiple data tables), MySQL can only use the primary key and the foreign key data type is the same when the index, or even if the establishment of the
Indexes are not used
4. If the query condition of the WHERE clause uses the comparison operator like and Regexp,mysql only if the first character of the search template is not a wildcard
Use indexes. For example, if the query condition is like ' abc% ', MySQL will use the index, and if the condition is like '%abc ', MySQL will not use the index.
5. In an order by operation, MySQL uses the index only if the sort condition is not a query condition expression. However, in the search for multiple data tables
In the inquiry, even if an index is available, those indexes have little effect in speeding up the order by operation.
6, if a data column contains a number of duplicate values, even if it is indexed it will not have a good effect. For example, if a data column contains the net
Something like "0/1" or "y/n" equivalent, there is no need to create an index for it.

7, the index is useful in the case of too much. Basically, as long as the index is established, in addition to the above mentioned index will not be used, in other cases, as long as the use of
In the Where condition, the order by field, the table fields, are generally valid. Indexing is an effective way to build an index. Why else would you use it? If you are not sure
Whether the index established on a field has an effect, as long as the actual test under the comparison of execution time is known.

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.