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

Query planner sort analysis incorrectly allows index key pattern plugin fields to provide sort

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.6.4
    • 2.6.5, 2.7.7
    • Querying
    • None
    • ALL
    • Hide

      use test;
       
      db.sorthashed.insert([
          {str:'bravo'},
          {str:'alpha'},
          {str:'tango'},
          {str:'charlie'}
      ]); // intentionally inserted out of alpha order, field in question is `str`
      db.sorthashed.find({}).sort({str:1}).pretty(); // shows in order
       
      db.sorthashed.ensureIndex({str:'hashed'},{background:false});
      db.sorthashed.find({}).sort({str:1}).pretty(); // shows in order
       
      db.sorthashed.find({str: {$in: ['bravo', 'alpha', 'tango', 'charlie']}}).sort({str:1}) // shows out of order

      Show
      use test; db.sorthashed.insert([ {str: 'bravo' }, {str: 'alpha' }, {str: 'tango' }, {str: 'charlie' } ]); // intentionally inserted out of alpha order, field in question is `str` db.sorthashed.find({}).sort({str:1}).pretty(); // shows in order db.sorthashed.ensureIndex({str: 'hashed' },{background: false }); db.sorthashed.find({}).sort({str:1}).pretty(); // shows in order   db.sorthashed.find({str: {$ in : [ 'bravo' , 'alpha' , 'tango' , 'charlie' ]}}).sort({str:1}) // shows out of order
    • 0

    Description

      It seems when query planner uses hashed index for search, the same hashed index will be used for sorting. The use-case is a light modification of use-case listed in SERVER-13899

      Reproduced on mongod-2.6.4

      Attachments

        Issue Links

          Activity

            People

              rassi J Rassi
              korum Konstantin Kardamanov
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: