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

Add example for $or case to the sorting with indexes tutorial

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • None
    • manual, Server
    • None

    Description

      RE:
      http://docs.mongodb.org/manual/tutorial/sort-results-with-indexes/#sort-and-index-prefix
      http://docs.mongodb.org/manual/reference/operator/query/or/#or-and-sort-operations

      It would be nice if there was an example of the effect of $or on sorted results. The second reference says indexes can be used to satisfy sort in the case of $or (presumably if all requirements are met) but doesn't really mention if there are any additional requirements.

      What if only one of the indexes for one of the $or branches satisfies the sort criteria?

      Since branches are evaluated independently they could potentially independently satisfy the sort too (a merge-sort at the top-level cannot be avoided), but I do not know the implemented behavior.

      Attachments

        Activity

          People

            kay.kim@mongodb.com Kay Kim (Inactive)
            andrew.ryder@mongodb.com Andrew Ryder (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              1 year, 14 weeks, 1 day ago