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