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

Query optimization is doing a big scan for searches involves $in

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.5
    • Affects Version/s: 1.3.4
    • Component/s: Querying
    • None
    • Environment:
      Mac OSX 10.5.8
      MongoDB: 1.3.3

      As described in http://bit.ly/bURxwn

      > db.hits.findOne()

      { "_id":ObjectId("4ba5a0409a59dc523d0a81dc"),
      "date": 1510,
      "user": 21176417,
      "word": 1,
      "list": [994953325, 2000523166]
      }
      > db.hits.count()
      8663354
      > print(db.hits.totalIndexSize())
      1279240064
      > db.hits.find({d: {$gte:1500, $lte:1510}, w: {$in:[275, 317]} }).explain()

      {
      "cursor" : "BtreeCursor d_1_w_1_u_1",
      "startKey" : {
      "d" : 1500,
      "w" : 275,
      "u" :

      { "$minElement" : 1 }


      },
      "endKey" : {
      "d" : 1510,
      "w" : 317,
      "u" :

      { "$maxElement" : 1 }


      },
      "nscanned" : 2866468,
      "n" : 5033,
      "millis" : 44465,
      "allPlans" : [
      {
      "cursor" : "BtreeCursor d_1_w_1_u_1",
      "startKey" : {
      "d" : 1500,
      "w" : 275,
      "u" :

      { "$minElement" : 1 }


      },
      "endKey" : {
      "d" : 1510,
      "w" : 317,
      "u" :

      { "$maxElement" : 1 }


      }
      },
      {
      "cursor" : "BasicCursor",
      "startKey" : {
      },
      "endKey" : {
      }
      }
      ]
      }

      Eliot replies: right now its not looking all all the sub-regions, just going from the front to back we can optimize at some point

        1. index_check8.js
          0.7 kB
          Alex Dong

            Assignee:
            aaron Aaron Staple
            Reporter:
            alexdong Alex Dong
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: