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

[CQF] Intersection of DNF intervals can be incorrect

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 6.3.0-rc0
    • None
    • None
    • None
    • Query Optimization
    • Fully Compatible
    • ALL
    • QO 2023-01-09, QO 2023-01-23

    Description

      Intersecting DNF intervals can sometimes lead to less strict bounds than expected. If we call intersectDNFIntervals with the following:

      {
          {
              {=Variable [a]}
           ^ 
              {(Variable [b], Variable [c])}
          }
      }
      

      The result** is

      {
          {
              [b >= a ? MaxKey : a, min(max(a,b), min(a,c))]
          }
       U 
          {
              [max(max(a,b), min(a,c)), c <= a ? MinKey : a]
          }
       U 
          {
              (max(a,b), min(a,c))
          }
      }
      

      If we have a=3, b=0, and c=3 then our original interval is [3,3] ^ (0, 3) = nothing. The result from intersectDNFIntervals is

      {
          {
              [3, 3]
          }
       U 
          {
              nothing
          }
       U 
          {
              nothing
          }
      }
      

      which is [3,3]. This error seems to come from an auxiliary interval.

      **
      In reality the explain printed out is below, but its hard to read so I decoded it into min/max and ternary

      {
          {
              {[(If  [] BinaryOp [Gte] Variable [b] Variable [a] Const [maxKey] Variable [a] ), (If  [] BinaryOp [Lte] (If  [] BinaryOp [Gte] Variable [a] Variable [b] Variable [a] Variable [b] ) (If  [] BinaryOp [Lte] Variable [a] Variable [c] Variable [a] Variable [c] ) (If  [] BinaryOp [Gte] Variable [a] Variable [b] Variable [a] Variable [b] ) (If  [] BinaryOp [Lte] Variable [a] Variable [c] Variable [a] Variable [c] ) )]}
          }
       U 
          {
              {[(If  [] BinaryOp [Gte] (If  [] BinaryOp [Gte] Variable [a] Variable [b] Variable [a] Variable [b] ) (If  [] BinaryOp [Lte] Variable [a] Variable [c] Variable [a] Variable [c] ) (If  [] BinaryOp [Gte] Variable [a] Variable [b] Variable [a] Variable [b] ) (If  [] BinaryOp [Lte] Variable [a] Variable [c] Variable [a] Variable [c] ) ), (If  [] BinaryOp [Lte] Variable [c] Variable [a] Const [minKey] Variable [a] )]}
          }
       U 
          {
              {((If  [] BinaryOp [Gte] Variable [a] Variable [b] Variable [a] Variable [b] ), (If  [] BinaryOp [Lte] Variable [a] Variable [c] Variable [a] Variable [c] ))}
          }
      }
      

      Attachments

        Activity

          People

            matt.boros@mongodb.com Matt Boros
            matt.boros@mongodb.com Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: