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

index-only query apparently not executed as index-only

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.4
    • Component/s: Querying
    • None
    • Environment:
      Window 7, single node
    • ALL

      I was working through the exercises in the training course in the indexing section. As a variation from the instructions, one of the students tried to explain() what should have been an index-only query, but it was not reported as such by explain. To recreate, load the twitter.tweets collection from the training sample data set. Then:

      > db.tweets.find({'user.friends_count:{$gt:100},
                        'user.followers_count':{$gt:100}},
           {'user.friends_count':1, _id:0}).explain();
      
      {
              "cursor" : "BtreeCursor user.friends_count_1_user.followers_count_1",
              "nscanned" : 26377,
              "nscannedObjects" : 25984,
              "n" : 25984,
              "millis" : 458,
              "nYields" : 0,
              "nChunkSkips" : 0,
              "isMultiKey" : false,
              "indexOnly" : false,
              "indexBounds" : {
                      "user.friends_count" : [
                              [
                                      100,
                                      1.7976931348623157e+308
                              ]
                      ],
                      "user.followers_count" : [
                              [
                                      100,
                                      1.7976931348623157e+308
                              ]
                      ]
              }
      }
      >
      

      Note the indexOnly field in the explain() result is false, even though the selection list only includes the first field of the index key.

            Assignee:
            Unassigned Unassigned
            Reporter:
            cwestin Chris Westin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: