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

allow $expr with comparison bounded on both sides with same type to use a non-multikey index

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • QO 2022-07-11, QO 2022-07-25, QO 2022-08-08, QO 2022-08-22, QO 2022-09-05, QO 2022-09-19

      Similarly to SERVER-31760 it's possible to rewrite $expr with $gt/$lt expression to an indexable MatchExpression.

      I believe the two clear cases of this are:

      • bounded on both ends comparison to same type, i.e. {$and:[{$gte:["$x",0]}, {$lt:["$x",100]}]}  can be rewritten to {x:{$gte:0, $lt:100}
      • comparison to type and'ed with $type comparison to same type, i.e. {$and:[{$lt:["$sys_created_on",ISODate("2012-02-28T03:04:49Z")]},{$eq:\\{$type:"$sys_created_on"},"date"}]}

      I think the first case would be more common in "normal use" the second can be used to force the type bracketing semantics in aggregation comparisons.

            Assignee:
            james.wahlin@mongodb.com James Wahlin
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            4 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: