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

Index bounds are not detected correctly

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.2
    • Component/s: Querying
    • None

      Documents with two fields: {sort:..,x:...}
      Index on {sort:1,x:1}

      The query on "x" sorted by the sort field doesn't detect proper index bounds for x:

      > db.test.find({x:{$gte:1,$lte:3}}).sort({sort:1}).explain("executionStats").executionStats.executionStages.inputStage.indexBounds
      { "sort" : [ "[MinKey, MaxKey]" ], "x" : [ "[MinKey, MaxKey]" ] }
      

      However, adding an all-inclusive condition on "sort" into the query fixes the problem:

      > db.test.find({sort:{$gte:MinKey},x:{$gte:1,$lte:3}}).sort({sort:1}).explain("executionStats").executionStats.executionStages.inputStage.indexBounds
      { "sort" : [ "[MinKey, MaxKey]" ], "x" : [ "[1.0, 3.0]" ] }
      

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            alex.komyagin@mongodb.com Alexander Komyagin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: