IIRC, a rule of thumb is that an index can only be used for search queries that use all columns from a point and to the left. For example, an index for columns (a, b, c, d) can be used if you request (a), (a, b), (a, b, c) or (a, b, c, d) but not on (a, c), for example.
This is the result of how indexes are built; the last column is indexed, then for each value of this column an ββindex is created for the next column, etc.
Edit: as BQ indicates, the DBMS can scan the full part β a β of the index and search in part β b β (I did not know that this was really done). However, this is not as fast as an index that can use the rule as described above (OTOH may be faster than a full table scan).
Personally, I do not think that this should be intentionally involved. If perf is enough to bother with a given query that you are considering which indexes are needed, you can also give it the correct ones.
source share