I have a collection with document like:
{
_id: "",
reportId: "a",
accountId: "",
....
}
Now my query pattern is like:
db.saleReport.find({reportId: "e6044e8a", "accountId":{$in: ["a","b"] }).sort({"_id":1});
I have created a compound index with:
db.saleReport.createIndex({reportId:1,accountId:1})
The above index is getting used only in query stage. There is a sort stage added even to sort on _id field.
Should I add _id also as part of index? Isn't the _id field stored in index already to uniquely identify the record?