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

incorrect use of sparse index to sort query results

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.2.2
    • 2.5.5
    • Querying
    • Major Change
    • ALL

    Description

      In some cases, sorting a query results in the use of a sparse index, which in turn results in a lesser number of documents being returned than would normally be returned by the query. This strikes me as incorrect.

      Example:

      Suppose I have a collection "foo" that contains 1000 documents. 750 of those documents include a value for the field "bar", while the other 250 do not. Suppose I have a sparse index "bar_1" on the field "bar". The index will contain the 750 documents that have a value for the field.

      The following query results in 1000 documents:
      db.foo.find()

      The following query results in only 750 documents, despite the identical query parameters:
      db.foo.find().sort(

      { bar: 1 }

      )

      I understand why this behaves the way it does, but in my opinion the behavior is incorrect.

      Attachments

        Issue Links

          Activity

            People

              benety.goh@mongodb.com Benety Goh
              mhurne Matt Hurne
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: