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

Mongodb Count is slow

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 4.2.0
    • None
    • None

    Description

      Hi,
      I am trying to improve count using covered queries but its taking ~5sec to return the response.

      Is this behavior expected or there is something I can do to improve this.

      Please find details below-

      There is collection with 6 million records

      consider each document to be something like this

      { "_id": "523453252", "type": "test" }

      i have a single field index on "type"

       when I execute following command
      db.test.explain("executionStats").find({type:{$in:["test","test1","test2"]}},{type:1,_id:0}).count()

      the number of keys examined are ~5.9 million
      number of docs examined are 0
      even though there are no docs examined i.e nothing is loaded from disk
      and the query is using only index the count is taking ~5sec
      Please let me know if there is anything that can be done to improve count response time.

      Attachments

        1. scr1.png
          scr1.png
          204 kB
        2. scrnsht.png
          scrnsht.png
          210 kB

        Activity

          People

            eric.sedor@mongodb.com Eric Sedor
            virinchisamineni@gmail.com virinchi samineni
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: