jeromelebel / MongoHub-Mac

Mac Native Mongodb Client
2.43k stars 159 forks source link

Remove default sorting value {"_id": 1} #216

Open Bossa573 opened 9 years ago

Bossa573 commented 9 years ago

my database contains a collection with index {"my_key": 1}

if I run the query :

{"my_key": "some_value"}

and leave the sorting value as empty, the query will become

db.myCollection.find({"my_key": "some_value"}).sort({ "_id": 1}).skip(0).limit(30)

and the database will perform a FULL db scan as there's no suitable index for this query

Here is the quote from mongodb support email sent by us about this issue:

Please note, the "_id" field is a line reference number, not  an actual _id