-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
-
Fully Compatible
-
QO 2023-09-04
There are a couple of scenarios in which the necessity of creating an SBE slot depends on the characteristics of an SBE plan (for example, $now and shardFilter). This ticket will focus on shardFilter, but it remains a question for other scenarios.
There are a couple of proposed solutions on how best to handle this scenario:
- (Currently used for shardFilterer) Globally allocate and fill a slot before running ABT lowering, such as in cqf_get_executor.cpp. These slots may not end up being used, but the solution is simple and unlikely to cause issues/bugs in the future. Note (idea from Nick): we could also allocate these slots in the constructor of RuntimeEnvironment.
- Make RuntimeEnvironment non-const and create the slots as-needed from within the lowering (or other) code, when it becomes clear that the slot is needed. This is nice because it creates the slot if it's needed and makes intuitive sense, but in some scenarios the need for it might be optimized out, and it requires making RuntimeEnvironment non-const.
- Prior to execution of the SBE plan, perform a "second-pass" walk in which we analyze the plan, see if a shard filterer is called for, and create the slot if so. This is nice because everything happens in one place and the slot is created if and only if needed, but it requires a second round of walking which could have performance implications.
The task of this ticket is to decide what the best solution is and implement it for shard filtering, then to file a ticket to make the improvement in the other analogous cases.