[SERVER-78962] Check on feasibility to perform boolean simplification before parameterization Created: 13/Jul/23  Updated: 02/Feb/24

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Peter Volk Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-78752 An incorrect plan can be written to t... Closed
is related to SERVER-75079 Simplify boolean expressions before f... Closed
Assigned Teams:
Query Optimization
Sprint: QO 2024-02-05, QO 2024-02-19
Participants:

 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. 


Generated at Thu Feb 08 06:39:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.