Mongodb – When _id is present in the projection, is the index on _id used for the query

mongodb-3.0mongodb-3.2mongodb-3.4

My query is

db.new.find({'a':{'$gt':200}, 'b':{'$lt': 30}}, 
            {'a':1, 'c':1}
).sort({'c':-1})

Indexes present are (a,b), (a,c), (c), (a,b,c), (_id)

When I check with explain('allPlansExecution'), I see that the index on _id is not used anywhere. However, since _id has not been suppressed in the projection, shouldn't it be used? Is there any possibility of it being used implicitly in such cases?

Best Answer

No, there is no need (in that query) to use _id index. There is no sort nor selection what need that index. Second, index (a,b) is not needed, it takes space and extra effort to keep updated. Index (a,b,c) answers all questions when keys a and b is queried.