I've been playing around with the MongoDB C# driver for the first time and I'm finding some strange results in performance. When I query a collection with 3 million records with ordering and .Take(1) the reponse is nearly instantanious (3ms.). But when I .Take(2) on the same query it takes up to 10 seconds. The right index is in place and it's a very simple collection with test data.
MongoClient client = new MongoClient();
MongoServer server = client.GetServer();
var database = server.GetDatabase("db_name");
var collection = database.GetCollection<MyType>("collection_name");
var query = from c in collection.AsQueryable<MyType>()
where c.SearchString.Contains(searchString)
orderby c.SearchString
select c.SearchString;
List<string> results = query.Take(2).ToList();