One reason for slow use of not in MySQL is that the field type does not match.

Source: Internet
Author: User

Recently, the customer's response to a page is getting slower and slower. It takes more than a dozen seconds to complete the operation.

SQL is not complex, probably because: Select field from table 1 where field 1 not in (select Field 2 from table 2)

The number of tables 1 and 2 is tens of thousands, and the data volume is not large. The technicians checked the index and did not change the data with not exists and left join.

It took several days to find that the field type of field 1 is int, and the field type of field 2 is varchar. therefore, the field type of field 2 is changed to int, and the result execution speed is within 1 second.

 

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.