MySQL indexing principle and slow query optimization

Source: Internet
Author: User

MySQL uses a B + Tree index. Data is stored on disk, so if the index is based on a binary tree, this involves many times the number of disk i/o,i/o depends on the height of the tree, greatly reducing the speed of the query. With the B + tree, this multi-path search tree structure allows three times I/O to implement millions data queries.

Principles for indexing:

The leftmost prefix matching principle, very important principle, MySQL will always match right until it encounters a range query (>, <, between, like) to stop the match, such as a = 1 and B = 2 and C > 3 and D = 4 If set (A,b,c,d) Shun The index of the order, D is not indexed, if the establishment (A,B,D,C) index can be used, a,b,d order can be arbitrarily adjusted.

Reference Links:

Http://tech.meituan.com/mysql-index.html

MySQL indexing principle and slow query optimization

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.