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

Wrong index bounds when using "hint"

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.3
    • Component/s: Querying
    • None
    • ALL
    • Hide

      I have the following two indexes:

      {Groups: 1, Duplicate: 1, NotFound: 1, DontShow: 1, TSCreated: 1, FacebookShares: -1}, {name: 'DateGroupIndex-FacebookShares'}
      {Groups: 1, Duplicate: 1, NotFound: 1, DontShow: 1, TSCreated: 1, TwitterShares: -1}, {name: 'DateGroupIndex-TwitterShares'}
      

      A) When I run the following query:

      .find({Groups:1,Duplicate:0,NotFound:0,DontShow:0,TSCreated:{$lt:1405695600,$gt:1405609200}}).hint("DateGroupIndex-FacebookShares").limit(10).sort({FacebookShares: -1}).explain()
      
      "cursor" : "BtreeCursor DateGroupIndex-FacebookShares"
      ...
      "indexBounds": {
      ...
      "TSCreated" : [
      		[
      				-Infinity,
      				1405695600
      		]
      ],
      ...}
      

      B) And when I run same query without calling "hint", the index bounds for TSCreated is properly computed, although it's not the proper index which is picked up:

      "cursor" : "BtreeCursor DateBasicIndex-TwitterShares"
      ...
      "indexBounds": {
      ...
      "TSCreated" : [
      		[
      				1405609200,
      				1405695600
      		]
      ],
      ...}
      
      
      Show
      I have the following two indexes: {Groups: 1, Duplicate: 1, NotFound: 1, DontShow: 1, TSCreated: 1, FacebookShares: -1}, {name: 'DateGroupIndex-FacebookShares' } {Groups: 1, Duplicate: 1, NotFound: 1, DontShow: 1, TSCreated: 1, TwitterShares: -1}, {name: 'DateGroupIndex-TwitterShares' } A) When I run the following query: .find({Groups:1,Duplicate:0,NotFound:0,DontShow:0,TSCreated:{$lt:1405695600,$gt:1405609200}}).hint( "DateGroupIndex-FacebookShares" ).limit(10).sort({FacebookShares: -1}).explain() "cursor" : "BtreeCursor DateGroupIndex-FacebookShares" ... "indexBounds" : { ... "TSCreated" : [ [ -Infinity, 1405695600 ] ], ...} B) And when I run same query without calling "hint", the index bounds for TSCreated is properly computed, although it's not the proper index which is picked up: "cursor" : "BtreeCursor DateBasicIndex-TwitterShares" ... "indexBounds" : { ... "TSCreated" : [ [ 1405609200, 1405695600 ] ], ...}

      It seems like than when using a range matching {$gt: XX, $lt YY} and forcing an index with "hint", the parser can properly parse the lower bound value. I've tried switching $gt and $lt places, it's all the same.

            Assignee:
            ramon.fernandez@mongodb.com Ramon Fernandez Marina
            Reporter:
            giudicelli Frédéric Giudicelli
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: