Mysql failure to prevent the index principle

 

Index prevent failure of principle

 

1. When you use an index, the best you can to build an index field gave use. Not only provide efficient query.
2. Best left-prefix rule, meaning that when and if you have been to establish a composite index of the multiple field index, the most left-prefix to follow most laws, referring to the query from the leftmost in the forefront of the beginning of the index and the index can not be skipped columns.
in principle:

  • The first index can not fall
  • Intermediate index not fall

3. the column index not do anything (calculation function (automatic or manual) type conversion), the index will lead to failure of the steering full table scan.
4. A storage engine can not be used in a range of column index in the right column, after the failure of the whole range of the index.
5. Try to use a covering index (an index to access only query (the index column and query the same)), to reduce the select *.
6.mysql not equal in use (! = Or <>) can not be used when the index will lead to a full table scan.
7.is null, is not null can not use the index, so the data in the table should not be NULL.
8.like wildcard beginning ( '% abc ...') or ( '% abc% ...') , mysql failure index table scan operation becomes fulfilled, using ( 'abc%') index not fail.
9. String failure index without single quotation marks.
10. less or, the index will fail when it is used to connect.


Small summary:

 

 

refer:

https://blog.csdn.net/weixin_34122810/article/details/89534628

Guess you like

Origin www.cnblogs.com/-wenli/p/12182617.html