I am trying to create a compound index but not entirely sure what i should apply it on to get most out of performance.
{
status: A - this can be one of three values
reason: B - this can be one of eight values
indicator: true - boolean flag
date1: ISO Date - this may or may not be present
date2: ISO Date - always present
date3: ISO Date - always present
}
The query is to find any documents of a particular status, indicator set as true and where the reason is not in a list of given reasons, and if date1 is set then any where date1 < today. It is then to return the top result ordered by date2 first, if there are two records with the same date2, then to use date3 as a second order and return that.
I have gone for a compound index of date1:1, reason:1, status: 1. But i'm really not sure if that is right and if I should include the other query fields and the sorted fields in the index too, any help much appreciated.
Thanks,