Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7637235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:53:10+00:00 2026-05-31T07:53:10+00:00

I installed the lastest MongoDB 64 bit DB and official C# driver as of

  • 0

I installed the lastest MongoDB 64 bit DB and official C# driver as of 13 Marh 2012. I am getting some unexpected performace results with cursors.

The following code will retrieve and loop through 500,000 records at about 26.8 k / sec on my Core 2 Duo 2 GHz laptop:

    var query = Query.EQ("_H._t", "Car");
    var cursor = mc.FindAs<RoctObj>(query);
    double priceTot = 0d;

    foreach (RoctObj item in cursor)
    {
        Car car = (Car)item._H;
        priceTot += car.Price;
    }

That seems reasonable. Next, I adjusted the query so that only 721 results are returned. The code takes over 1.1 seconds longer to execute than if the foreach segment is replaced with:

    long i = cursor.Count();

Given the speed of the first example, 721 records should only take a fraction of a second to iterate. I know there are some other overheads, but they should be that bad. I don’t understand why I am getting +1.1 seconds.

Any ideas?

EDIT

Here is the alternate query. Note that the query time isn’t the question. It’s the iteration time.

    var query = Query.And(
        Query.LTE("_H.Price", BsonDouble.Create(80000d)).GTE(BsonDouble.Create(40000d)),
        Query.LTE("_H.Cylinders", BsonDouble.Create(8d)).GTE(BsonDouble.Create(4d)),
        Query.LTE("_H.Capacity", BsonDouble.Create(3000d)).GTE(BsonDouble.Create(2000d)),
        Query.LTE("_H.TopSpeed", BsonDouble.Create(200d)).GTE(BsonDouble.Create(100d))
        );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:53:11+00:00Added an answer on May 31, 2026 at 7:53 am

    MongoDB does not return all the results at once, it returns a cursor which reads data off the database one record at a time, as your application asks for it (i.e. during your iterations) which may be why it is slower.

    Running a count() simply returns the amount of matches found but without data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I installed the latest stable xampp package, and received the following error page when
environment: client windows 7 ultimate x64 TortoiseSVN(lastest) server ubuntu 10.4 svn (it installed by
I installed the latest JDK 1.6.0_25 on my Windows 7 64-bit machine. I then
I installed the lastest version of 'Eclipse for PHP' (Eclipse Helios). The PHP editor
I installed latest 64-bit Python 2.5. I run the shell, and try to import
I have successfully installed and run mongodb on my macbook pro with the c++
I installed the latest Qt SDK. I see that though mine is a 32-bit
I'm trying to use MongoDB with MATLAB. Although there is no supported driver for
Just installed the latest SDK for iPhone 2.1. When I go to File ->
I installed the latest version of Wordpress and added the WP-Syntax plugin (and also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.