Re: MongoDB C# driver blocks after fetching 100 records

23 views
Skip to first unread message

Dan Pasette

unread,
May 2, 2013, 10:19:47 AM5/2/13
to mongo...@googlegroups.com
This group is used for questions pertaining to development of MongoDB.  For questions specific to client drivers or usage, please post to the mongodb-user group: https://groups.google.com/forum/?fromgroups=#!forum/mongodb-user or the C# group (as you did): https://groups.google.com/forum/?fromgroups=#!forum/mongodb-csharp.  I'm sure you will get a response shortly.

Best,
Dan

On Thursday, May 2, 2013 10:02:23 AM UTC-4, mash wrote:
Hi

I posted this question on MongoDB c# driver group...but I've not received any response...hence posting it here.

I'm trying to fetch some records based on a simple query. The code snippet is posted below. The query is supposed to return 3000K records...but when I execute, the application blocks after getting 100 records. Then after couple of minutes it fetches the remaining N records. Is there a config setting I'm missing? Has anyone experienced similar issue?

Running MongoDB 2.4.3
I have the right indexes and verified using explain that the query is using the same index.

            MongoClient client = new MongoClient("mongodb://myserver:27017"); // connect to localhost
            MongoServer server = client.GetServer();
            MongoDatabase omni = server.GetDatabase("MyDB");

            MongoCollection<BsonDocument> coll = omni.GetCollection<BsonDocument>("MyCollection");

            var query = Query.And(Query.Matches("category", "foo"),
                                  Query.Matches("refid", "bar"),
                                  Query.Exists("Topic_ID")
                                  );

            int count = 0;
            var cursor = coll.Find(query);

            foreach (var doc in cursor)
            {
                Console.WriteLine("i=" + (++count));
            }


NOTE: For testing purposes I removed the query and changed it to "findAll()"; event then in the first iteration Mongo returns ~ 100 records and then on each iteration it pauses for 30 secs and returns 7K at a time. Why does it pause?

Thanks
MyCom
Reply all
Reply to author
Forward
0 new messages