MySQL optimization index (index How to Avoid Failure)

Built table SQL:
Here Insert Picture Description
index failure should avoid
Here Insert Picture Description
the full value of my favorite match:
Here Insert Picture Description
the best left-prefix rule : If a multi-column index, the most left-prefix to comply with the law, referring to the query from the leftmost in the forefront of the beginning of the index and does not skip index columns. (Take the lead in Big Brother can not die, the middle brother can not be broken)
Here Insert Picture Description
not in the index column do anything (computing, function (automatic or manual) type conversion), will lead to failure while the index turned full table scan (not counting the index column)
Here Insert Picture Description
Storage Engine You can not use an index range condition rightmost column (index full fail after a range)
Here Insert Picture Description
to make use of a covering index (only access to the index query (indexed columns and query uniform)), reduction SELECT *
Here Insert Picture Description
Here Insert Picture Description
MySQL using the not equal (! = or < >) can not be used when the index will lead to a full table scan
Here Insert Picture Description
is null, is not null can not use an index
Here Insert Picture Description
like to begin with wildcard characters ( '% abc ...') mysql index failed to fulfill the operation becomes a table scan (like the right percentage increase )
Here Insert Picture Description
problem: index (using a covering index avoid full table scan) when the solution is not used like '% string%'
Here Insert Picture Description
after CREATE iNDEX idx_user_nameAge ON tbl_user (NAME, age) to create an index
Here Insert Picture Description
number of the correct order to be effective
Here Insert Picture Description
string without single quotes index failed (string in quotation marks)
Here Insert Picture Description
less or, the index will fail when it is used to connect
Here Insert Picture Description
a small sum
Here Insert Picture Description
optimization summary formulas:
Here Insert Picture Description

Published 217 original articles · won 125 Like · views 10000 +

Guess you like

Origin blog.csdn.net/qq_39885372/article/details/104187557