<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:31:10 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-53525] aggregate  $lookup is very slow&#65292; it is not equal to the explain() time&#12290; (22244ms:414ms)</title>
                <link>https://jira.mongodb.org/browse/SERVER-53525</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;If there are no conditions(.explain(&quot;executionStats&quot;))&#65292; it is very slow&#65292;the query and slow log as following:&lt;br/&gt;
&lt;b&gt;query:&lt;/b&gt;&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;soloop_KdTdfHyZ_shard_2:SECONDARY&amp;gt; &lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;soloop_KdTdfHyZ_shard_2:SECONDARY&amp;gt; db.getCollection(&apos;video_info&apos;).aggregate( [{&quot;$lookup&quot;: {&quot;from&quot;: &quot;user_info&quot;, &quot;localField&quot;: &quot;soloop_id&quot;, &quot;foreignField&quot;: &quot;soloop_id&quot;, &quot;as&quot;: &quot;docs_userTab&quot;}}, {&quot;$lookup&quot;: {&quot;from&quot;: &quot;video_check&quot;, &quot;localField&quot;: &quot;feed_id&quot;, &quot;foreignField&quot;: &quot;_id&quot;, &quot;as&quot;: &quot;docs_videoCheck&quot;}}, {&quot;$match&quot;: {&quot;$and&quot;: [{&quot;video_type&quot;: 2}, {}, {}, {}]}}, {&quot;$count&quot;: &quot;cnt&quot;}])&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ &quot;cnt&quot; : 229671 }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;soloop_KdTdfHyZ_shard_2:SECONDARY&amp;gt; &lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;&lt;b&gt;slowlog:&lt;/b&gt;&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;2020-12-28T18:18:59.219+0800 I COMMAND  [conn187] command soloop_user.video_info appName: &quot;MongoDB Shell&quot; command: aggregate { aggregate: &quot;video_info&quot;, pipeline: [ { $lookup: { from: &quot;user_info&quot;, localField: &quot;soloop_id&quot;, foreignField: &quot;soloop_id&quot;, as: &quot;docs_userTab&quot; } }, { $lookup: { from: &quot;video_check&quot;, localField: &quot;feed_id&quot;, foreignField: &quot;_id&quot;, as: &quot;docs_videoCheck&quot; } }, { $match: { $and: [ { video_type: 2.0 }, {}, {}, {} ] } }, { $count: &quot;cnt&quot; } ], cursor: {}, lsid: { id: UUID(&quot;15396d73-c647-41f8-8823-5074a58c285f&quot;) }, $clusterTime: { clusterTime: Timestamp(1609150708, 27), signature: { hash: BinData(0, 350DC28A151DB4D3B2A9CEF11EE2A7AFD9556ABA), keyId: 6867230734357102603 } }, $readPreference: { mode: &quot;secondaryPreferred&quot; }, $db: &quot;soloop_user&quot; } planSummary: IXSCAN { video_type: 1, status: 1, create_time: 1 } keysExamined:229671 docsExamined:229671 cursorExhausted:1 numYields:1806 nreturned:1 reslen:358 locks:{ Global: { acquireCount: { r: 1841012 }, acquireWaitCount: { r: 1881 }, timeAcquiringMicros: { r: 741652 } }, Database: { acquireCount: { r: 920506 } }, Collection: { acquireCount: { r: 920505 } } } protocol:op_msg 22244ms&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;





&lt;p&gt;If there are conditions(.explain(&quot;executionStats&quot;))&#65292; it is very quic&#65292;the query and log as following:&lt;br/&gt;
&lt;b&gt;query sql:&lt;/b&gt;&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; db.getCollection(&apos;video_info&apos;).explain(&quot;executionStats&quot;).aggregate( [{&quot;$lookup&quot;: {&quot;from&quot;: &quot;user_info&quot;, &quot;localField&quot;: &quot;soloop_id&quot;, &quot;foreignField&quot;: &quot;soloop_id&quot;, &quot;as&quot;: &quot;docs_userTab&quot;}}, {&quot;$lookup&quot;: {&quot;from&quot;: &quot;video_check&quot;, &quot;localField&quot;: &quot;feed_id&quot;, &quot;foreignField&quot;: &quot;_id&quot;, &quot;as&quot;: &quot;docs_videoCheck&quot;}}, {&quot;$match&quot;: {&quot;$and&quot;: [{&quot;video_type&quot;: 2}, {}, {}, {}]}}, {&quot;$count&quot;: &quot;cnt&quot;}])&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;&lt;b&gt;log:&lt;/b&gt;&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;2020-12-28T18:23:41.109+0800 I COMMAND  [conn187] command soloop_user.video_info appName: &quot;MongoDB Shell&quot; command: explain { explain: { aggregate: &quot;video_info&quot;, pipeline: [ { $lookup: { from: &quot;user_info&quot;, localField: &quot;soloop_id&quot;, foreignField: &quot;soloop_id&quot;, as: &quot;docs_userTab&quot; } }, { $lookup: { from: &quot;video_check&quot;, localField: &quot;feed_id&quot;, foreignField: &quot;_id&quot;, as: &quot;docs_videoCheck&quot; } }, { $match: { $and: [ { video_type: 2.0 }, {}, {}, {} ] } }, { $count: &quot;cnt&quot; } ], cursor: {} }, verbosity: &quot;executionStats&quot;, lsid: { id: UUID(&quot;15396d73-c647-41f8-8823-5074a58c285f&quot;) }, $clusterTime: { clusterTime: Timestamp(1609150988, 104), signature: { hash: BinData(0, C97A46869BBB3B61A9BD3FD52F538B6A8337A312), keyId: 6867230734357102603 } }, $readPreference: { mode: &quot;secondaryPreferred&quot; }, $db: &quot;soloop_user&quot; } planSummary: IXSCAN { video_type: 1, status: 1, create_time: 1 } numYields:1794 reslen:2569 locks:{ Global: { acquireCount: { r: 3596 }, acquireWaitCount: { r: 31 }, timeAcquiringMicros: { r: 11652 } }, Database: { acquireCount: { r: 1798 } }, Collection: { acquireCount: { r: 1797 } } } protocol:op_msg 414ms&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;



&lt;p&gt;If there are conditions(.explain(&quot;executionStats&quot;))&#65292; it is very slow&#65292;the slow log as following:&lt;/p&gt;</description>
                <environment></environment>
        <key id="1577801">SERVER-53525</key>
            <summary>aggregate  $lookup is very slow&#65292; it is not equal to the explain() time&#12290; (22244ms:414ms)</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="3">Duplicate</resolution>
                                        <assignee username="edwin.zhou@mongodb.com">Edwin Zhou</assignee>
                                    <reporter username="1147952115@qq.com">y yz</reporter>
                        <labels>
                    </labels>
                <created>Mon, 28 Dec 2020 10:25:15 +0000</created>
                <updated>Fri, 22 Jan 2021 21:35:32 +0000</updated>
                            <resolved>Fri, 22 Jan 2021 21:35:32 +0000</resolved>
                                                                    <component>Aggregation Framework</component>
                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="3578592" author="JIRAUSER1257066" created="Fri, 22 Jan 2021 20:16:11 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=1147952115%40qq.com&quot; class=&quot;user-hover&quot; rel=&quot;1147952115@qq.com&quot;&gt;1147952115@qq.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;The discrepancy in runtime you&apos;ve observed in .explain(&quot;executionStats&quot;) is because only the part of the query listed under the $cursor stage would actually be executed. That means using .explain() and $lookup will not execute the $lookup stage. This issue was fixed in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-29421&quot; title=&quot;Aggregation executionStats or allPlansExecution explain modes behave incorrectly with $limit&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-29421&quot;&gt;&lt;del&gt;SERVER-29421&lt;/del&gt;&lt;/a&gt;. &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-21784&quot; title=&quot;Track &amp;#39;nReturned&amp;#39; and &amp;#39;executionTimeMillis&amp;#39; execution stats for each aggregation pipeline stage and expose via explain&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-21784&quot;&gt;&lt;del&gt;SERVER-21784&lt;/del&gt;&lt;/a&gt; improved &quot;executionStats&quot; explain for agg to report an &quot;executionTimeMillisEstimate&quot; field for every stage in the pipeline. If you were to run this explain after upgrading to 4.4, you will see time estimates associated with all stages in the pipeline including $lookup.&lt;/p&gt;

&lt;p&gt;Best,&lt;br/&gt;
Edwin&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="389305">SERVER-29421</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </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_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 21 Jan 2021 16:49:44 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        3 years, 2 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></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>edwin.zhou@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            3 years, 2 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>edwin.zhou@mongodb.com</customfieldvalue>
            <customfieldvalue>1147952115@qq.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hynfgf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hy98dz:</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_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;mongo version: 3.6.13&lt;br/&gt;
linux 3.10, centos 7&lt;/p&gt;</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                    <customfieldvalue><![CDATA[edwin.zhou@mongodb.com]]></customfieldvalue>
    

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

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