MySQLSQL optimization: an out-of-the-box Index _ MySQL

Source: Internet
Author: User
MySQLSQL Optimization: An index that is out of the way. this is the 4th SQL optimization article.

Here, I mainly express my point of view that if an index does not exist, it should be eliminated, leaving it in the way.

During the period from 15:39:01 to 15:55:00, we found two problems in a business system:

This phenomenon is also very common in the database, that is, a slow query, the initiator, the execution of ttrojan slow, the subsequent query should be blocked quickly, resulting in the emergence of a series of long queries

After diagnosis, we found that a dateline index exists in a table. this index will cause the MySQL Optimizer to select an incorrect execution plan, resulting in a large number of SQL congestion in the future. about 5000 queries blocked each other.

If the dateline index is not used, the effect is good. the following comparison:

1. Comparison of execution plans

2. Comparison of Execution time:

Therefore, our feedback to developer shoes is that the dateline index is erased.

At first, we didn't know whether the index was provided for other queries, so we were scared that it would cause other queries to slow down.

However, after this period of time, no other queries are actually using this index.

Indexing is a good thing, but don't be greedy.

Good Luck!

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.