[SERVER-81888] Path fusion rewrite to mark the root of any constant path subtree as constant Created: 05/Oct/23  Updated: 09/Jan/24

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

Type: Improvement Priority: Major - P3
Reporter: Alya Berciu Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: M9
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-79367 Optimize projections in Bonsai Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

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.

 


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