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

Improve index usage for constants inside of `let`

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Execution

      Neither of the following operations use an index on total:

      db.test.aggregate([ {
            $match: {
               $expr: {
                  $let: {
                     vars: {
                        total: 100,
                     },
                     in: { $gt: [ "$total", "$$total" ] }
                  }
               }
            }
         }]) 
      db.test.aggregate([ {
            $match: {
               $expr: {
                  $let: {
                     vars: {
                        unused_var: 'unused_value',
                     },
                     in: { $gt: [ "$total", 100 ] }
                  }
               }
            }
         }]) 

      We should improve this.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            christopher.harris@mongodb.com Chris Harris
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: