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

Support internal expr comparison operators when determining clustered collection scan bounds

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.3.0-rc0, 7.0.13
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • v7.0, v6.0
    • QO 2023-12-11

      Currently, query on clustered collection will not use the index

      db.coll.find({$expr: {$gt: ["$_id", <..>]}})


      However, same syntax with a secondary index will work.

      Because of slight semantic difference between match $gt and aggregation $gt
      (match does type-bracketing, aggregation uses the specified BSON comparison order for values of different types), we have two sets of comparison match expressions:
       regular ones like $gt and $_internalExprGt which use slightly different logic.

      When computing bounds for secondary index scan, $_internalExpr* operators are supported, however, they are not supported in clustered collection scan bounds:

      There might be a reason for it, because of semantic difference, so we need to either fix it by adding internal expr comparison operations to the code, linked about, or add a comment about why we can't do it.

            james.harrison@mongodb.com James Harrison
            ivan.fefer@mongodb.com Ivan Fefer
            0 Vote for this issue
            15 Start watching this issue