<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:06:39 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>[DOCS-12985] Too slow $facet with index</title>
                <link>https://jira.mongodb.org/browse/DOCS-12985</link>
                <project id="10380" key="DOCS">Documentation</project>
                    <description>&lt;h2&gt;&lt;a name=&quot;Description&quot;&gt;&lt;/a&gt;Description&lt;/h2&gt;
&lt;p&gt;I noticed that using $facet with large amount of data is a lot slow than making multiple calls to database. In my example, my collection has 160000 records, 56000 is ChannelCode &quot;dtm&quot;.&lt;/p&gt;

&lt;p&gt;Using $facet it takes 600ms to complete:&lt;/p&gt;

&lt;p&gt;db.getCollection(&apos;application_view&apos;).aggregate(&lt;br/&gt;
    [&lt;br/&gt;
        {&lt;br/&gt;
            &quot;$match&quot;: &lt;/p&gt;
{ &quot;ChannelCode&quot;: &quot;dtm&quot; }
&lt;p&gt;        }, &lt;br/&gt;
        {&lt;br/&gt;
            &quot;$facet&quot;: {&lt;br/&gt;
                &quot;results&quot;: [&lt;br/&gt;
                    { &quot;$sort&quot;: &lt;/p&gt;
{ &quot;ApplicationDate&quot;: 1 }
&lt;p&gt; },&lt;br/&gt;
                    &lt;/p&gt;
{ &quot;$skip&quot;: 0 }
&lt;p&gt;,&lt;/p&gt;
                    { &quot;$limit&quot;: 10 }
&lt;p&gt;                 ],&lt;br/&gt;
                &quot;total&quot;: [ &lt;/p&gt;
{ &quot;$count&quot;: &quot;count&quot; }
&lt;p&gt; ]&lt;br/&gt;
            }&lt;br/&gt;
        }&lt;br/&gt;
    ]&lt;br/&gt;
)&lt;/p&gt;

&lt;p&gt;Making 2 calls to db  takes 600ms too, but when I add an index &lt;/p&gt;
{StatusCode: 1, ApplicationDate: 1}
&lt;p&gt; it decreases to 54ms, but the example with $facet continues the same:&lt;/p&gt;

&lt;p&gt;db.getCollection(&apos;application_view&apos;).aggregate([&lt;br/&gt;
    {$match: {&quot;ChannelCode&quot;: &quot;dtm&quot;}},&lt;br/&gt;
    {$sort: {ApplicationDate: 1}},&lt;br/&gt;
    {$skip: 0},&lt;br/&gt;
    {$limit: 10}&lt;br/&gt;
])&lt;/p&gt;

&lt;p&gt;db.getCollection(&apos;application_view&apos;).aggregate([&lt;br/&gt;
    {$match: {&quot;ChannelCode&quot;: &quot;dtm&quot;}},&lt;br/&gt;
    {$count: &quot;count&quot;}&lt;br/&gt;
])&lt;/p&gt;

&lt;p&gt;&#160;Why this is happening? How can I improve the time with $facet? &lt;br/&gt;
Thanks in advance.&lt;/p&gt;

&lt;h2&gt;&lt;a name=&quot;Scopeofchanges&quot;&gt;&lt;/a&gt;Scope of changes&lt;/h2&gt;

&lt;h2&gt;&lt;a name=&quot;ImpacttoOtherDocs&quot;&gt;&lt;/a&gt;Impact to Other Docs&lt;/h2&gt;

&lt;h2&gt;&lt;a name=&quot;MVP%28WorkandDate%29&quot;&gt;&lt;/a&gt;MVP (Work and Date)&lt;/h2&gt;

&lt;h2&gt;&lt;a name=&quot;Resources%28ScopeorDesignDocs%2CInvision%2Cetc.%29&quot;&gt;&lt;/a&gt;Resources (Scope or Design Docs, Invision, etc.)&lt;/h2&gt;
</description>
                <environment>Windows</environment>
        <key id="906921">DOCS-12985</key>
            <summary>Too slow $facet with index</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="12300">Won&apos;t Do</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="murilokunze">Murilo Kunze</reporter>
                        <labels>
                            <label>facet</label>
                    </labels>
                <created>Mon, 26 Aug 2019 16:49:37 +0000</created>
                <updated>Mon, 26 Aug 2019 19:45:33 +0000</updated>
                            <resolved>Mon, 26 Aug 2019 19:43:41 +0000</resolved>
                                    <version>3.6.14</version>
                                                        <due></due>
                            <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="2387197" author="ravind.kumar" created="Mon, 26 Aug 2019 19:43:41 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=murilokunze&quot; class=&quot;user-hover&quot; rel=&quot;murilokunze&quot;&gt;murilokunze&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;&#160;The best place for you to issue your question is on our &lt;a href=&quot;https://groups.google.com/forum/?nomobile=true#!forum/mongodb-user&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;MongoDB Community Support Forum&lt;/a&gt;. The MongoDB Community Support forum is a community forum where experienced MongoDB users and MongoDB Community Support Engineers participate in discussions. I would strongly recommend including the data you have here to help with diagnostics and discussions.&lt;/p&gt;

&lt;p&gt;The MongoDB Documentation Team cannot provide product support or diagnostics. However, if your post to the google group results in a documentation change request, we would be happy to assist at that time.&lt;/p&gt;

&lt;p&gt;Regards,&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;Ravind Kumar&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;Senior Technical Writer, Server &lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="228430" name="db.stats.json" size="349" author="murilokunze" created="Mon, 26 Aug 2019 16:47:37 +0000"/>
                            <attachment id="228431" name="indices.json" size="393" author="murilokunze" created="Mon, 26 Aug 2019 16:47:37 +0000"/>
                            <attachment id="228436" name="with $facet.js" size="5911" author="murilokunze" created="Mon, 26 Aug 2019 16:45:59 +0000"/>
                            <attachment id="228433" name="with facet.PNG" size="21647" author="murilokunze" created="Mon, 26 Aug 2019 16:46:10 +0000"/>
                            <attachment id="228435" name="without facet-1.js" size="4965" author="murilokunze" created="Mon, 26 Aug 2019 16:46:03 +0000"/>
                            <attachment id="228434" name="without facet-2.js" size="4451" author="murilokunze" created="Mon, 26 Aug 2019 16:46:06 +0000"/>
                            <attachment id="228432" name="without facet.PNG" size="50880" author="murilokunze" created="Mon, 26 Aug 2019 16:46:11 +0000"/>
                    </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>Mon, 26 Aug 2019 19:43:41 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 24 weeks, 2 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>jess.mokrzecki@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            4 years, 24 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>murilokunze</customfieldvalue>
            <customfieldvalue>ravind.kumar</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hvmurz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hvbmtz:</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_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hvmh1b:</customfieldvalue>

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