Optimize $or queries to perform like $in if all clauses are on the same field

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      For performance reasons, you would generally decide to use $in in scenarios where they apply over $or.

      However, some scenarios apply that you would be forced to use a $or in order to add more complex clauses or ranges to your query. For something like find all values of a where a > 10 and a < 20 or a > 30 and a < 50, you would be forced to use a $or query even though the only field being used in the index is a.

      $or should be able to detect when it does not need to run as multiple queries and perhaps handle single field cases like this in a performant way.

            Assignee:
            David Storch
            Reporter:
            Osmar Olivo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: