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

Optimise $all/$and to select smallest subset as initial index bounds

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.6.12, 3.0.7, 3.1.9
    • Component/s: Querying
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Backport Completed:
    • Sprint:
      Quint Iteration 3, QuInt A (10/12/15)

      Description

      Currently clauses in a $all will be evaluated in the order that they are provided to the query. This can lead to cases where a superset is being searched to find values that are contained within a smaller subset of the wanted values.

      Consider trying to find all documents that have tags showing that they are an Italian and have a Michelin star within a collection of restaurants. There will be a large number of documents with the tag "Italian" but very few with the tag "Michelin".

      If the tags are entered into the $all clause in alphabetical order, the search will take longer as the larger set of "Italian" documents must be searched again for the "Michelin" tag. If the tag order is reversed, then we search the smaller set of "Michelin" matching documents to find those who match "Italian".

      The optimisation here would be to remove the dependency on the order of documents in an $all clause.

      Changes in this case should handle situations where the entities within the $all clause are not simply fields, but also documents which may have several levels of depth.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                4 Vote for this issue
                Watchers:
                16 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: