Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1838

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.3
    • Fix Version/s: None
    • Component/s: Linq
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible

      Description

      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?

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: