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

Check on feasibility to perform boolean simplification before parameterization

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Optimization
    • QO 2024-02-05, QO 2024-02-19, QO 2024-03-04, QO 2024-03-18, QO 2024-04-01, QO 2024-04-15, QO 2024-04-29, QO 2024-05-13, QO 2024-05-27, QO 2024-06-10, QO 2024-06-24, QO 2024-07-08

      During the implementation of SERVER-78752 the way how IndexScans are being considered equal was changed to also include the IET (link to follow once PR was merged). In several cases the IETs hinder a collapse of Index scans as the IETs are different yet everthing else is the same. E.g. for this query: 

      {c: 1, $or: [{a:{$gte:1,$lte:1}, b:2}, {a:1, b:2, d:3}]}

       the two  nodes of the $or branch have the same limits etc. but different IETs:

      ---------------Child:
      ------------------IXSCAN
      ---------------------indexName = hari_king_of_the_stove
      ---------------------keyPattern = { a: 1, b: 1 }
      ---------------------direction = 1
      ---------------------bounds = field #0['a']: [1, 1], field #1['b']: [2, 2]
      ---------------------iets = (iets { a: 1, b: 1 } (a: 1 (eval $eq #0)) (b: 1 (eval $eq #1)))
      ---------------------nodeId = 1
      ---------------------fetched = 0
      ---------------------sortedByDiskLoc = 1
      ---------------------providedSorts = {baseSortPattern: {}, ignoredFields: [a, b]}
      
      ---------Child 1:
      ------------IXSCAN
      ---------------indexName = hari_king_of_the_stove
      ---------------keyPattern = { a: 1, b: 1 }
      ---------------direction = 1
      ---------------bounds = field #0['a']: [1, 1], field #1['b']: [2, 2]
      ---------------iets = (iets { a: 1, b: 1 } (a: 1 (intersect (eval $lte #3) (eval $gte #4))) (b: 1 (eval $eq #1)))
      ---------------nodeId = 3
      ---------------fetched = 0
      ---------------sortedByDiskLoc = 1
      ---------------providedSorts = {baseSortPattern: { a: 1 }, ignoredFields: [b]} 

      The difference between both hinders a collapse of the two IndexScans. If the query were to be Boolean-optimized before it is parameterized then the parameterized query would not contain the intersect in the IET an hence the two branches could be collapsed. This should be discussed in the broader view of how much we optimize a query before it is parameterized. 

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            peter.volk@mongodb.com Peter Volk
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: