mysql tuning One: Avoid full table scan in where order by involves field setting index 1. Avoid using it in where condition ! = > < , otherwise the engine will give up using the index and perform a full table scan. 2. Avoid the where condition to judge null, otherwise the engine will give up the use of the index and perform a full table scan. You can set null to 0 to indicate 3. The where condition avoids or to judge, otherwise the engine will give up the use of the index and perform a full table scan. select id from tablename where name = ' Tom ' or name = ' Que ' Error select id from tablename where name = ' Tom ' union all (union query) select id from tablename where name = ' Que ' True 4 . Do not use fuzzy query, otherwise the engine will give up using the index and perform a full table scan. select id from tablename where like ' %ang% ' Error To improve efficiency, consider full-text search. 5.in not in用法 select id from tablename where score in(90,91,92) Error For consecutive numbers you can use between select id from tablename where score between 90 and 91 6. Avoid modifying the value of the field, otherwise the engine will give up using the index and perform a full table scan. select name from tablename where score + 1 = 60 Error select name from tablename where score = 60 - 1 True where condition ' = ' If the function expression cannot be calculated on the left side, the engine will give up using the index and perform a full table scan. -- Try to avoid functional operations on fields in the where statement 7. Many times using exists instead of in is a good choice select name from tablename wherer name in ( select name from tablename1) Erroe select name from tablename where exists ( select name from tablename1 where name = tablename.name) True