I have a compound index and an index on a single field A
. If in a find query, the compound index was chosen as the winning plan, and the results are sorted by the field A
, will field A
's index be used to sort it?
Asked
Active
Viewed 36 times
0

Bear Bile Farming is Torture
- 4,317
- 4
- 27
- 61
1 Answers
1
Unfortunately, no.
MongoDB cannot use different indexes for sorting and document selection.
Note that it can use a compound index for sorting, i.e. if the compound index were on {a:1, otherfield:1}
, that index can be used for selection by multiple fields, and sorting by a
.

Joe
- 25,000
- 3
- 22
- 44