Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-7574

Comment on: "manual/tutorial/sort-results-with-indexes.txt"

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • None
    • manual, Server

    Description

      In the document: https://docs.mongodb.or/manual/tutorial/sort-results-with-indexes/ (for version 3.2 and 3.0 both)

      The last example and description has a problem:
      ---------------
      ....For example, the following operations specify a sort document of

      { c: 1 }

      , but the query documents do not contain equality matches on the preceding index fields a and b:

      db.data.find( { a:

      { $gt: 2 }

      } ).sort(

      { c: 1 }

      )
      db.data.find(

      { c: 5 }

      ).sort(

      { c: 1 }

      )
      These operations will not efficiently use the index

      { a: 1, b: 1, c: 1, d: 1 }

      and may not even use the index to retrieve the documents.
      ---------------------
      In my testing actually "find( { a:

      { $gt: 2 }

      } ).sort(

      { c: 1 }

      )" example uses index! But the description says it will not use index.
      Please check that out, and confirm it.

      Attachments

        Activity

          People

            Unassigned Unassigned
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              1 year, 14 weeks, 2 days ago