This is a question that I've had forever.
As far as I know the order of indices matter. So an index like [first_name, last_name]
is not the same as [last_name, first_name]
, right?
If I only define the first index, does it mean that it will only used for SELECT * FROM table WHERE first_name="john" AND last_name="doe";
and not for SELECT * FROM table WHERE last_name="doe" AND first_name="john";
?
Since I am using a ORM, I have no idea in which order these columns are going to be called. Does that mean that I have to add indices on all permutations? That is doable if I have a 2 column index, but what happens if my index is on 3 or 4 columns?