MySQL index usage analysis

Topic SQL:
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
value, range or sorting, is to give a general order by the scope of
the following examples C3 role in sorting instead of looking for, so use two index fields
Here Insert Picture Description
to find the best sort order is consistent with the construction of the index might otherwise occur using filesort, since the third layer order can not know for sorting mysql own file
Here Insert Picture Description
following example c2, c3 no filesort for sorting, into c3, c2 have the filesort, order by the order can not mess
Here Insert Picture Description
with c1, c2 fields two index, but c2, c3 for sorting, no filesort
Here Insert Picture Description
group by basically every sort, there will be a temporary table is generated and the group by the order can not mess
Here Insert Picture Description
general recommendations:

  1. For the key index, try to choose for the current query filter of a better index
  2. In selecting a combination of the time index, the best current query in a field filterability index field order, the better position more to the left.
  3. In selecting a combination of the time index, may be able to select a query containing the current index in the where clause of the additional fields
  4. As far as possible by analyzing the wording of statistics and adjust query to achieve the purpose of selecting the appropriate index
Published 217 original articles · won 125 Like · views 10000 +

Guess you like

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