MySQL Query optimization rules

Source: Internet
Author: User
Tags mysql query mysql query optimization

1, please do not use distinct in select; #会用到临时表2, try not to select *, and you should query the specified number of fields that need to be used;3, do not federate on two large tables, either inline or out-of-union. For the case that two or more tables need to be federated, you can do two or more database queries;4, in the Where condition, compare the data columns of the same type as much as possible;5, in the Where condition, try to make the indexed data columns appear separately in the beginning of the comparison expression;6, in the Where condition, according to the data column to exclude the amount of non-conditional data from the order of many to few, if you can not determine how much to exclude data, in general expressions use =,! =, <> to take precedence over >, <, >=, <=, which takes precedence over like, if the value in the Where condition is a number, do not use single quotation marks for type conversion, if you use like pattern matching in the where condition, do not use wildcard characters at the beginning of the pattern%;7, do not char/the non-binary attribute in the Where conditionvarchar field, case conversion;8, if possible, do not use GROUP by in Select, and if it is necessary, please contact the supervisor to confirm;

MySQL Query optimization rules

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.