Thank you so much for your reply, really appreciate your time.
I was wondering, why all the fields except _id has a ascending order (chatId: 1).
One more thing, I have never worked with partial indexes. Why would it be better in my case? I don’t have any other queries to this collection. On what’s the filter query I shall use to create the partial index?
Partial indexes index only documents that answer a specific criteria. In this case only isDeleted : false.
This makes the index small as possible for this query while focusing on not deleted marked messages.
If this criteria is present in all queries of this type it saves another indexed field as the system knows only false values are in this index.
{ partialFilterExpression: { isDeleted : false} }
Regarding the indexing order , having asc order is the default for equality fields but for sort fields its best to use the query order in the sort. In your case the only field that makes a difference is the _id which is sorted desc order thats why its the only one really need -1.