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

index bounds incorrect on compound index with simple query

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5.5
    • Component/s: Index Maintenance
    • None
    • ALL

      The following simple query on 'id' with range on 'date' does not properly bound the query on 'date'. In contrast, v2.4 was doing this properly.

      Version 2.5.5:

      > db.test.find({ id: "1537F3BDA01A95E403BFE4E0783B3D2BC2E2984FD492A21109468E939A39BB97", date: { $gte: new Date(1391212800000), $lte: new Date(1392076800000) } }).explain()
      { 
              "cursor" : "Complex Plan",
              "n" : 0,
              "nscannedObjects" : 0,
              "nscanned" : 0,
              "nscannedObjectsAllPlans" : 0,
              "nscannedAllPlans" : 0,
              "nYields" : 0,
              "nChunkSkips" : 0,
              "millis" : 0,
              "server" : "MongoDBLinux-3:27017",
              "stats" : {
                      "type" : "FETCH",
                      "works" : 2,
                      "yields" : 0,
                      "unyields" : 0,
                      "invalidates" : 0,
                      "advanced" : 0,
                      "needTime" : 0,
                      "needFetch" : 0,
                      "isEOF" : 1,
                      "alreadyHasObj" : 0,
                      "forcedFetches" : 0,
                      "matchTested" : 0,
                      "children" : [
                              {
                                      "type" : "KEEP_MUTATIONS",
                                      "works" : 1,
                                      "yields" : 0,
                                      "unyields" : 0,
                                      "invalidates" : 0,
                                      "advanced" : 0,
                                      "needTime" : 0,
                                      "needFetch" : 0,
                                      "isEOF" : 1,
                                      "children" : [
                                              {
                                                      "type" : "AND_HASH",
                                                      "works" : 1,
                                                      "yields" : 0,
                                                      "unyields" : 0,
                                                      "invalidates" : 0,
                                                      "advanced" : 0,
                                                      "needTime" : 0,
                                                      "needFetch" : 0,
                                                      "isEOF" : 1,
                                                      "flaggedButPassed" : 0,
                                                      "flaggedInProgress" : 0,
                                                      "children" : [
                                                              {
                                                                      "type" : "IXSCAN",
                                                                      "works" : 1,
                                                                      "yields" : 0,
                                                                      "unyields" : 0,
                                                                      "invalidates" : 0,
                                                                      "advanced" : 0,
                                                                      "needTime" : 0,
                                                                      "needFetch" : 0,
                                                                      "isEOF" : 1,
                                                                      "keyPattern" : "{ date: 1.0 }",
                                                                      "bounds" : {
                                                                              "date" : [
                                                                                      [
                                                                                              ISODate("2014-02-01T00:00:00Z"),
                                                                                              ISODate("2014-02-11T00:00:00Z")
                                                                                      ]
                                                                              ]
                                                                      },
                                                                      "isMultiKey" : 0,
                                                                      "yieldMovedCursor" : 0,
                                                                      "dupsTested" : 0,
                                                                      "dupsDropped" : 0,
                                                                      "seenInvalidated" : 0,
                                                                      "matchTested" : 0,
                                                                      "keysExamined" : 0,
                                                                      "children" : [ ]
                                                              },
                                                              {
                                                                      "type" : "IXSCAN",
                                                                      "works" : 0,
                                                                      "yields" : 0,
                                                                      "unyields" : 0,
                                                                      "invalidates" : 0,
                                                                      "advanced" : 0,
                                                                      "needTime" : 0,
                                                                      "needFetch" : 0,
                                                                      "isEOF" : 0,
                                                                      "keyPattern" : "{ id: 1, date: 1 }",
                                                                      "bounds" : {
                                                                              "id" : [
                                                                                      [
                                                                                              "1537F3BDA01A95E403BFE4E0783B3D2BC2E2984FD492A21109468E939A39BB97",
                                                                                              "1537F3BDA01A95E403BFE4E0783B3D2BC2E2984FD492A21109468E939A39BB97"
                                                                                      ]
                                                                              ],
                                                                              "date" : [
                                                                                      [
                                                                                              {
                                                                                                      "$minElement" : 1
                                                                                              },
                                                                                              {
                                                                                                      "$maxElement" : 1
                                                                                              }
                                                                                      ]
                                                                              ]
                                                                      },
                                                                      "isMultiKey" : 0,
                                                                      "yieldMovedCursor" : 0,
                                                                      "dupsTested" : 0,
                                                                      "dupsDropped" : 0,
                                                                      "seenInvalidated" : 0,
                                                                      "matchTested" : 0,
                                                                      "keysExamined" : 0,
                                                                      "children" : [ ]
                                                              }
                                                      ]
                                              }
                                      ]
                              }
                      ]
              }
      } 
      

      version 2.4:

      > db.test.find({ id: "1537F3BDA01A95E403BFE4E0783B3D2BC2E2984FD492A21109468E939A39BB97", date: { $gte: new Date(1391212800000), $lte: new Date(1392076800000) } }).explain()
      { 
              "cursor" : "BtreeCursor id_1_date_1",
              "isMultiKey" : false,
              "n" : 0,
              "nscannedObjects" : 0,
              "nscanned" : 0,
              "nscannedObjectsAllPlans" : 0,
              "nscannedAllPlans" : 0,
              "scanAndOrder" : false,
              "indexOnly" : false,
              "nYields" : 0,
              "nChunkSkips" : 0,
              "millis" : 3,
              "indexBounds" : {
                      "id" : [
                              [
                                      "1537F3BDA01A95E403BFE4E0783B3D2BC2E2984FD492A21109468E939A39BB97",
                                      "1537F3BDA01A95E403BFE4E0783B3D2BC2E2984FD492A21109468E939A39BB97"
                              ]
                      ],
                      "date" : [
                              [
                                      ISODate("2014-02-01T00:00:00Z"),
                                      ISODate("2014-02-11T00:00:00Z")
                              ]
                      ]
              },
              "server" : "MongoDBLinux-3:27017"
      }
      

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            antoine Antoine Girbal
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: