MySQL in does not walk index

Source: Internet
Author: User
Tags mysql in

Before optimization

Select* from Erp_helei mg WHERE mg.num = 602 and mg.pid in (10002559,10002561,10002562,10002563,10002564,10002598,10002 599,10002600,10002601,10002602,10002603,10002604,10002648,10002649,10002667,10002668,10002676,10002558)


After optimization


Select* from Erp_helei mg WHERE mg.num = 602 and Mg.pid in (' 10002559 ', ' 10002561 ', ' 10002562 ', ' 10002563 ', ' 10002564 ', ' 100 02598 ', ' 10002599 ', ' 10002600 ', ' 10002601 ', ' 10002602 ', ' 10002603 ', ' 10002604 ', ' 10002648 ', ' 10002649 ', ' 10002667 ', ' 10002668 ', ' 10002676 ', ' 10002558 ')

Reason

The PID column is a char type and must be added ' to go through the index, otherwise a full table scan will become slower as the table grows

This article is from the "Age volt" blog, please make sure to keep this source http://suifu.blog.51cto.com/9167728/1783375

MySQL in does not walk 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.