Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5646

Model.count using aggregate pipeline

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      I noticed `Model.count` was slow, after looking into the logs I noticed its doing `db.model.aggregate([{'$match': {} }, { '$group': { _id: 1, count:

      { '$sum': 1 }

      } }])`. This seems very very odd and explains why this is slow. I would expect it to use `db.model.find({}).count()` (if i do `Model.collection.count` it is fast, as i would expect cause its using the db.model.find({}).count()`)

            Assignee:
            Unassigned Unassigned
            Reporter:
            jonathag@cisco.com Jonathon Gardner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: