MySQL's efficient coverage index

Source: Internet
Author: User

A very efficient and useful index---the overlay index in MySQL.

Overlay index in layman's words, it is only when the select is used to fetch the data, without having to make two select related tables. The leaf nodes of such indexes also contain the data of their index.

SELECT * FROM table_name;

Select Id,name from table_name;

In most cases, we should only query the columns we need to know, so that the packets sent between the networks are small, the network traffic is reduced, and the speed of your query is naturally improved.

Select a from table_name where B , such a query, all know that the index should be added on top B,

Process of query:

first go to index B to find its corresponding index,

The correct data rows are then retrieved based on the index area.

So a go is two searches, can you get the data through a single retrieval?

If you want to get the data through a single retrieval, then the index should contain the data relative to its index, so is it possible?

Read this, of course know possible.

ALTER TABLE_NAME ADD index (B,A);

Adding an index like this can be done,

See if the overwrite index is used;

Explain select;

·······

·······

······

Extra:use Index

If a red font portion appears, it indicates that an overlay index is used.

The InnoDB engine is further above the overlay index:

All InnoDB engines have a primary key ID, a transaction ID, a rollback pointer, a non-primary key ID,

His query would be either a non-primary key ID or overwrite it to get the primary key ID.


MySQL's efficient coverage index

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.