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

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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.3
    • Linq
    • None
    • 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

        Activity

          People

            robert@mongodb.com Robert Stam
            sblomstrand Sten Blomstrand
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: