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

Simple database query is taking over 10 mins even with a suitable index

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • None

      We have a collection (called childData) with the following indexes:

      m_childDataCollection.CreateIndex(IndexKeys.Ascending(MongoChildData.ItemIdProperty).Ascending(MongoChildData.ChildIdProperty));
      m_childDataCollection.CreateIndex(IndexKeys.Ascending(MongoChildData.RedundantTimeProperty));
      

      This query runs very fast (less than a second) and returns 59631 :

      db.childdata.find(\{ ItemId: ObjectId('596f322ba28f4b1240f1c2e9') }).count()
      

      This query takes around 15 minutes:

      db.childdata.find(\{ ItemId: ObjectId('596f322ba28f4b1240f1c2e9') }, \{ItemId : 1, ChId : 1}).toArray()
      

      We are failing to understand why this second query takes so long even though it is using the index?

      Please note that I have also rebuilt these indexes completely. It took over 3 days to do this!

      Thanks
      Ian

        1. countoutput.txt
          1 kB
          Ian Hannah
        2. error.png
          25 kB
          Ian Hannah
        3. find_with_itemId_ChId.txt
          3 kB
          Ian Hannah
        4. find_with_itemId_ChId.txt
          1 kB
          Ian Hannah
        5. screenshot.png
          119 kB
          Ian Hannah

            Assignee:
            daniel.hatcher@mongodb.com Danny Hatcher (Inactive)
            Reporter:
            ihannah@meniscus.co.uk Ian Hannah
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: