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

Sort (Ascending|Descending) on non-indexed field (works|asserts)

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 1.2.4, 1.3.4
    • Querying
    • None
    • Ubuntu 9.10 x64

    Description

      If I run a sort query (with limit) on a collection in ascending order, everything operates properly:

      > db.signatures.find().sort(

      {numbb:1}

      ).limit(10)

      { "_id" : ObjectId("4b980bcb5506ca18cc00000d"), "numbb" : 2, "symbol" : "gen_raw_REG", "type" : "ssig", "signature" : BinData type: 2 len: 67 }

      .....

      But I actually want descending order:
      > db.signatures.find().sort(

      {numbb:-1}

      ).limit(10)
      error:

      { "$err" : "too much data for sort() with no index" }

      Curiously, a smaller limit works properly:
      > db.signatures.find().sort(

      {numbb:-1}

      ).limit(3)

      { "_id" : ObjectId("4b980ed75506ca18cc02d6fb"), "_types" : [ "Signature" ], "symbol" : "_ZN8LargeNet13doBuildInsideEv", "numbb" : 6323, "_cls" : "Signature", "signature" : BinData type: 2 len: 2364674, "type" : "ssig" }

      ....

      For reference, .limit(4) is apparently too large.

      If there's a good reason for this, so be it. I'm guessing, however, that this is due to the query optimizer doing quite different things depending on sort order.

      Attachments

        Activity

          People

            eliot Eliot Horowitz (Inactive)
            jdd John Demme
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: