<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:45:57 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-58954] Refactor and unify the code to optimize expressions in projections</title>
                <link>https://jira.mongodb.org/browse/SERVER-58954</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;As part of the work in&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-57749&quot; title=&quot;Query marked as SBE compatible, but later optimization sends it down an unimplemented path&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-57749&quot;&gt;&lt;del&gt;SERVER-57749&lt;/del&gt;&lt;/a&gt; we looked into cleaning up / standardizing code to optimize projection expressions, but found that doing so would involve a large overhaul of the existing code and that it is beyond the scope of the original ticket (which was about a late call to optimize() on a projection in SBE).&#160;&lt;/p&gt;

&lt;p&gt;To fix the issue of a late optimization as well as avoid the issue with &apos;find&apos; in current state producing sub-optimal plans for some queries, we instead suggest to do it earlier when building the projection AST. However, because we currently have an &lt;a href=&quot;https://github.com/mongodb/mongo/blob/2e35876d1beefc2d7f62aa935874370d82ce0672/src/mongo/db/exec/projection_executor_builder.h#L43-L48&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;optimize() method on a ProjectionNode&lt;/a&gt;, this causes there to be two ways in which we can potentially optimize a projection:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Parse the projection&lt;br/&gt;
Build ProjectionExecutor&lt;br/&gt;
Optimize ProjectionExecutor&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;&#160;&lt;br/&gt;
(new method)&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Parse projection&lt;br/&gt;
optimize it&lt;br/&gt;
Build ProjectionExecutor&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;The goal is to clean this up by ideally removing the optimize() method on the ProjectionNode, however, this is difficult since we rely on optimizations in certain cases with $lookup. In this situation we need to make sure that $lookup inner pipelines are not being&#160;optimized too early, as that might lead to incorrect positioning of the caching&#160;stage if certain variables have been&#160;optimized away. See &lt;a href=&quot;https://github.com/10gen/mongo/blob/master/src/mongo/db/pipeline/document_source_project.cpp#L79-L87&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this comment&lt;/a&gt;&#160;for this description:&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;One proposed approach that could be implemented as suggested by Ian is to include a new &quot;prepare&quot; method to DocumentSource that would mostly do nothing but in the case of&#160;DocumentSourceSingleDocumentTransformation can be used for the optimization purposes. This then would also require us to plumb through a call to optimize to the &apos;TransformerInterface&apos; of this DocumentSource for projections.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1835937">SERVER-58954</key>
            <summary>Refactor and unify the code to optimize expressions in projections</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="backlog-query-execution">Backlog - Query Execution</assignee>
                                    <reporter username="andrii.dobroshynski@mongodb.com">Andrii Dobroshynski</reporter>
                        <labels>
                    </labels>
                <created>Thu, 29 Jul 2021 19:07:37 +0000</created>
                <updated>Tue, 6 Dec 2022 01:04:22 +0000</updated>
                                                                                                <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="4084167" author="JIRAUSER1258488" created="Fri, 24 Sep 2021 20:28:36 +0000"  >&lt;p&gt;$bucket/$bucketAuto/$sortByCount are sugared $group stages. Just like&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-57749&quot; title=&quot;Query marked as SBE compatible, but later optimization sends it down an unimplemented path&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-57749&quot;&gt;&lt;del&gt;SERVER-57749&lt;/del&gt;&lt;/a&gt;,&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-60203&quot; title=&quot;Translation of the groupBy expression of a sugared $group is unimplemented&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-60203&quot;&gt;&lt;del&gt;SERVER-60203&lt;/del&gt;&lt;/a&gt;&#160;is related to the late optimization of expressions because $bucket/$bucketAuto/$sortByCount is desurgared first and then optimized.&lt;/p&gt;

&lt;p&gt;With the prospect of resolving&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-58954&quot; title=&quot;Refactor and unify the code to optimize expressions in projections&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-58954&quot;&gt;SERVER-58954&lt;/a&gt;, banning sugared $group stage from being pushed down to SBE for $group pushdown project.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="1786746">SERVER-57749</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10020">
                    <name>Gantt Dependency</name>
                                                                <inwardlinks description="has to be done after">
                                        <issuelink>
            <issuekey id="1786746">SERVER-57749</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1882880">SERVER-60203</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1883255">SERVER-60226</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25125"><![CDATA[Query Execution]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 24 Sep 2021 20:28:36 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        2 years, 19 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[<s><a href='https://jira.mongodb.org/browse/SERVER-57749'>SERVER-57749</a></s>]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>alexander.golin@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            2 years, 19 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>andrii.dobroshynski@mongodb.com</customfieldvalue>
            <customfieldvalue>backlog-query-execution</customfieldvalue>
            <customfieldvalue>yoonsoo.kim@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hzv5wf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr2ilj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hzus5j:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>