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

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Index Maintenance
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • 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. screenshot.png
          119 kB
        2. find_with_itemId_ChId.txt
          1 kB
        3. find_with_itemId_ChId.txt
          3 kB
        4. error.png
          error.png
          25 kB
        5. countoutput.txt
          1 kB

            Assignee:
            Danny Hatcher (Inactive)
            Reporter:
            Ian Hannah
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: