Mongo query is slow using C# driver but fast using mongo shell <p>I got very weird problem with MongoDB C# driver. I have a very simple query and I have a correct index for that query. When I run the query using MongoChef (and using the shell) I get the results in 22ms But when my app runs the same query it takes about 2.5mins to return answer (this is not due to network problems).</p> <p>I have checked in db.currentOp() and I saw that the op is indeed taking about 2.5 mins to finish and the query is the same as the one I ran manually and the execution plan do use the index. Any idea? Thanks</p> <p>P.S The problem is not with the size of the result set! I have tested with results set that have 0 results, 21 results and 600,000 results and in all of them the results was horrible! (above 2m for only 21 results which in the shell takes no time!)</p> <pre><code>{ "inprog": [ { "opid" : 53214, "active" : true, "secs_running" : 174, "microsecs_running" : 174085497, "op" : query, "ns" : db.collection, "query" : {{$query : {ParentId: 55, IsDeleted : false}}, {$orderby : {_id : -1}}}, "planSummary": IXSCAN {_id : 1}, "client" : ip:port, "desc" : conn121254, "threadId" : 0x1234567, "connectionId" : 1254651, "locks" : { "Global" : r, "MMAPV1Journal" : r, "Database" : r, "Collection" : R }, "waitingForLock" : false, "numYields" : 46963, "lockStats" : { "Global" : {acquireCount : { r : 93928}}, "MMAPV1Journal" : {acquireCount : { r : 46964} , acquireWaitCount : { r : 2 }, timeAcquiringMicros: { r : 2 } }, "Database" : {acquireCount : { r : 46964}}, "Collection" : {acquireCount : { r : 46964}} } } ] } </code></pre> <p>And the query that is running great on the shell (22ms)</p> <pre><code>db.collection.find({ParentId : 55, IsDeleted : false}).sort({_id : 1}) </code></pre> <p>C# code example :</p> <pre><code>MongoClient client = new MongoClient("mongodb://MongosServer01:27017,MongosServer02:27017,MongosServer03:27017,MongosServer04:27017"); var collection = client.GetServer().GetDatabase("db").GetCollection&lt;BsonDocument&gt;("collection"); var cursor = collection.Find(Query.And(Query.EQ("ParentId" , 55),Query.EQ("IsDeleted" , false))).SetSortOrder("_id").SetLimit(20); </code></pre>