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

    Details

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

      Description

      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);

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                57 Vote for this issue
                Watchers:
                36 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: