Fields in the order by clause should be indexed?

1

I'm reading a lot about using indexes in Mysql. I noticed that it really is necessary to know how to use it at the right time and in the appropriate columns, in order to make queries faster and not the other way around.

Now, imagine the following query:

select campoX 
from tabela 
where campoA = 1 
and campoB = 2 
and campoC = 3 
order by campoM

In this case, I created an index composed of the columns of the where: campoA, campoB, campoC. clause (using this same order)

My question concerns the order by field. Should I include the M field at the end of this same index to make my index workable?

Taking advantage of the same reasoning, if I used a group by in this query, should I also include it in this index?

    
asked by anonymous 14.08.2016 / 19:26

0 answers