Topic SQL:
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
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
following example c2, c3 no filesort for sorting, into c3, c2 have the filesort, order by the order can not mess
with c1, c2 fields two index, but c2, c3 for sorting, no filesort
group by basically every sort, there will be a temporary table is generated and the group by the order can not mess
general recommendations:
- For the key index, try to choose for the current query filter of a better index
- 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.
- 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
- As far as possible by analyzing the wording of statistics and adjust query to achieve the purpose of selecting the appropriate index