{user: 1, _id: -1}
And
{user: 1, subtype: 1, _id: -1}
The reason you have to scan all records with the second index on the
first collection is that you're sorting by _id, so you need to sort
all records for a given user manually. In the former case, the
optimizer was able to use the index to satisfy the sort.
On Dec 1, 9:48 am, Sergei Tulentsev <sergei.tulent...@gmail.com>
wrote:
> Hello everyone,
>
> So I have this collection, documents in which contain fields user, subtype
> and, of course, _id.
>
> I am doing these types of queries:
>
> - find({user: u}).sort({_id: -1}).skip(n).limit(m)
> - find({user: u, subtype: st}).sort({_id: -1}).skip(n).limit(m)