Causes of MySQL index failure

Examples of index failure:

1. The full value matches my favorite

  • Establish a few composite index fields, it is best to use a few fields. And used in order

2. The best left prefix rule

  • If multiple columns are indexed, the left-most prefix rule must be observed, which means that the query starts from the left-most front column of the index and does not skip the middle column of the index. (The big brother ca n’t die, the middle brother ca n’t be lost)

3. No more operations (calculation, function, (automatic or manual) type conversion) on the index column will cause the index to fail and turn to the token scan

4. The storage engine cannot use the right column of the range condition in the index. (All failures after the scope)

  • If the intermediate index column uses a range (>, <, like, etc.), all subsequent indexes are invalid

5. Use cover index as much as possible (only access the index query (the index column and the query column are the same)), reduce select *

6. Mysql cannot use the index when using the left blur that is not equal to (! =, <>) Or like, which will cause a full table scan

7, IS NULL and IS NOT NULL can not use the index

8. The index of the string without single quotes is invalid, because there is an implicit type conversion operation, which will cause the row lock to become a table lock and reduce SQL efficiency.

9. Use less, or use it to connect to the index will be invalid

Mantra

Guess you like

Origin www.cnblogs.com/zhuang229/p/12687979.html