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:
- 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.
- 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.