[SERVER-83427] [CQF] Improve constant folding for And/Or with a constant RHS if LHS is guaranteed to not return Nothing Created: 17/Nov/23  Updated: 24/Jan/24  Resolved: 04/Jan/24

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Ben Shteinfeld Assignee: Lynne Wang
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-82148 [CQF] Use parameter type information ... Closed
is depended on by SERVER-79622 [CQF] Improve intersectDNFIntervals b... Open
Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Sprint: QO 2023-11-27, QO 2023-12-11, QO 2023-12-25, QO 2024-01-08
Participants:

 Description   

Currently our constant folding implementation will ignore AND(..., false) and OR(..., true) in order to respect SBE's short circuiting semantics. This is because the LHS will evaluate to either a boolean or Nothing. In the case that the LHS evaluates to Nothing, SBE will not evaluate the RHS. That is why our constant folding cannot fold these expressions.

Interval simplification generates expressions that look like this, but we can prove that LHS will never return nothing, since there are no field accesses on the LHS, there are only constants, getParam() invocations, or BinaryOps.

This ticket is to improve constant folding to keep track of the Nothingness of expressions and make use of it in the case of AND/OR with a constant RHS.



 Comments   
Comment by Githook User [ 21/Dec/23 ]

Author:

{'name': 'Lynne Wang', 'email': 'lynne.wang@mongodb.com', 'username': 'lynne-wang'}

Message: SERVER-83427 Implemented nullability tracker in constant folding; improved constant folding of And/Or with a constant RHS if LHS is guaranteed to return a Non-Nothing value

GitOrigin-RevId: 49d0d677074e51f7a43a67d664269034ca170d67
Branch: master
https://github.com/mongodb/mongo/commit/b9a2dd479a41960f17a9ea5e6dafc049d9dbbe21

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