[SERVER-71584] [CQF] Share the implementation of Filter decomposition rewrite Created: 23/Nov/22  Updated: 29/Oct/23  Resolved: 08/Feb/23

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

Type: Improvement Priority: Major - P3
Reporter: Ben Shteinfeld Assignee: Svilen Mihaylov (Inactive)
Resolution: Fixed Votes: 0
Labels: refactor
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Participants:

 Description   

SERVER-70812 implemented an optimization at the end of ABT translation for find which decomposes an EvalFilter with a conjunction in a serial chain of Filter nodes for consistency with the agg codepath. This is helpful to perform before PathFusion in order to simplify the plan. There is already a similar rewrite implemented in the substitution phase this rewrite performs the filter decomposition described above with the following differences:

  1. It performs the decomposition one node at a time and relies on the RewriteContext's hasSubstituted bit to decide whether to do another pass, rather than perform the full decomposition at once. This makes it less obvious of how to share the optimization code between the two locations.
  2. It extracts the common path prefix. It is unclear to me whether this should be done in the translation version of this optimization.

The current state is not great, we need this optimization before PathFusion and during the substitution phase, and as a resultĀ  duplicate the code as the implementations are slightly different. This ticket tracks work to improve this situation; either refactor the code optimizations to be implemented in a shared file (handling the differences described above), or introduce a new phase done before PathFusion and remove the optimization as part of translation.



 Comments   
Comment by Githook User [ 08/Feb/23 ]

Author:

{'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'svilen-mihaylov'}

Message: SERVER-71584 [CQF] Share the implementation of Filter decomposition rewrite
Branch: master
https://github.com/mongodb/mongo/commit/d9057c75bca0e1b25181742d9170fe53e34be85b

Comment by David Percy [ 30/Nov/22 ]

either refactor the code optimizations to be implemented in a shared file (handling the differences described above), or introduce a new phase done before PathFusion and remove the optimization as part of translation.

The second one makes more sense to me. Splitting a conjunction into two Filter nodes is a simplifying / normalizing rewrite, just like constant folding. It's better to put these in the optimizer, because then the optimizer accepts a wider variety of inputs--it's not as sensitive to the exact shape of the ABT. And it's also good to keep the MQL to ABT translation as simple as possible.

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