-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
The motivation is related to SERVER-79367. Consider the following path:
Drop "a" * Field "a" p
Where p is some arbitrary path. If we try to convert to MakeObjSpec, we will fail to translate the PathComposeM because there is no way to encode "pass Nothing to p and set field 'a' to the output". This sort of path comes up when we have consecutive projection stages where we exclude a path and then set that path to something else.
Because we fail to translate, we will fallback to lowering, which is provably slow. We can do better. Note the following:
Drop "a" = Field "a" Const Nothing
=>
Field "a" Const Nothing * Field "a" p = Field "a" (Const Nothing * p) = Field "a" Const (p | Nothing)
If we can perform this rewrite, e.g. by setting the child of PathConst to (Const Nothing * p), then we can definitely translate a path of the form Field "a" Const c to MakeObjSpec/ get a better plan.
- depends on
-
SERVER-79367 Optimize projections in Bonsai
- Closed