MySQL building indexing and indexing use

Source: Internet
Author: User

Index creation Occasions:
①where the Back field is suitable for indexing
②order by sort fields suitable for indexing
③ index Overwrite that is, the field you are querying is the index that queries the data directly in the index. For example, select Name,age from man where Name,age itself has an index.
④ Table Query (foreign key set index) in a production activity, the foreign key index is not generally used. Instead, a normal index is used instead of the foreign key index.

⑤ Creating an indexed field requires a higher degree of dispersion, such as gender, which is not suitable for indexing, (the build will not use the index to walk the table scan form)


  

Index usage Guidelines
① field Independent SELECT * from man where id+2 =5 such queries are not used, i.e. the so-called field independence principle.
② left principle (when fuzzy query) like query time, left fixed may use to index. The left is not fixed and the index cannot be used.
③ composite Index You can use indexes when you use composite cables in full. Using the first index alone, you can use it to the index. Using the second field alone cannot be used to index.
④or principle the index can be used if both sides have indexes. An index that has no index cannot be used to the index, regardless of the order of the or conditions.

MySQL building indexing and indexing use

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.