Merge multiple .Where() clauses to a single $match before querying

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.3
    • Component/s: LINQ
    • None
    • None
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None

      My first issue here so please correct me if I make any mistakes posting it.

      The aggregation framework that the 2.* driver maps to only uses indexes for the first match (https://docs.mongodb.com/v3.2/reference/operator/aggregation/match/).

      I often pass aroung IQueryable to multiple layers in my applications that combine .Where(...) clauses to filter the result (depending on user input, access level etc).

      The resulting query that the driver produces translates every .Where() clause to a $match. This results in poor performance since the indexes are only used for the first $match.

      Would it be possible for the driver to combine these $match'es to a single $match?

            Assignee:
            Robert Stam
            Reporter:
            Sten Blomstrand
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: