Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-2274

Performance of count() on range check queries is worse than it should be

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.6.5
    • Component/s: Querying
    • Labels:
      None
    • Environment:
      Any

      Using the test script below this script reports about 50ms of time taken for the count query in the script. This is way too slow for a query that the query optimizer should resolve to a direct bsearch on the index, or so I assume.

      use test

      db.values.drop();
      db.values.ensureIndex(

      {value:1}

      );

      for (var i = 1; i <= 100000; i++) db.values.save(

      {value : i}

      );

      var t1 = new Date().getTime();
      db.values.count({value:{$gt:5000}});
      var t2 = new Date().getTime();

      (t2 - t1);

            Assignee:
            Unassigned Unassigned
            Reporter:
            remonvv Remon van Vliet
            Votes:
            57 Vote for this issue
            Watchers:
            35 Start watching this issue

              Created:
              Updated:
              Resolved: