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

Check on feasibility to perform boolean simplification before parameterization

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • None
    • Query Optimization
    • QO 2023-08-21, QO 2023-09-04, QO 2023-09-18, QO 2023-10-02, QO 2023-10-16, QO 2023-10-30, QO 2023-11-13, QO 2023-11-27, QO 2023-12-11

    Description

      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. 

      Attachments

        Activity

          People

            backlog-query-optimization Backlog - Query Optimization
            peter.volk@mongodb.com Peter Volk
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: