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: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • 0

      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:
            ivan.fefer@mongodb.com Ivan Fefer
            Reporter:
            christopher.harris@mongodb.com Chris Harris
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: