<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:29: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-52845] $exists works slowly</title>
                <link>https://jira.mongodb.org/browse/SERVER-52845</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;If you&apos;re doing a query with $exists, it takes much more time than doing a query by value.&lt;/p&gt;

&lt;p&gt;Example query:&#160;db.getCollection(&apos;test&apos;).find({status: {$exists: false}}, {}).count()&lt;br/&gt;
Explain looks like this:&lt;br/&gt;
 &quot;winningPlan&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;FETCH&quot;,&lt;br/&gt;
 &quot;filter&quot; : {&lt;br/&gt;
 &quot;status&quot; : {&lt;br/&gt;
 &quot;$not&quot; : &lt;/p&gt;
{
 &quot;$exists&quot; : true
 }
&lt;p&gt;}},&lt;br/&gt;
 &quot;inputStage&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;IXSCAN&quot;,&lt;br/&gt;
 &quot;keyPattern&quot; : &lt;/p&gt;
{
 &quot;status&quot; : 1.0
 }
&lt;p&gt;,&lt;br/&gt;
 &quot;indexName&quot; : &quot;status_1&quot;,&lt;br/&gt;
 &quot;isMultiKey&quot; : false,&lt;br/&gt;
 &quot;multiKeyPaths&quot; : &lt;/p&gt;
{
 &quot;status&quot; : []
 }
&lt;p&gt;,&lt;br/&gt;
 &quot;isUnique&quot; : false,&lt;br/&gt;
 &quot;isSparse&quot; : false,&lt;br/&gt;
 &quot;isPartial&quot; : false,&lt;br/&gt;
 &quot;indexVersion&quot; : 2,&lt;br/&gt;
 &quot;direction&quot; : &quot;forward&quot;,&lt;br/&gt;
 &quot;indexBounds&quot; : &lt;/p&gt;
{
 &quot;status&quot; : [ 
 &quot;[null, null]&quot;
 ]}
&lt;p&gt;}},&lt;/p&gt;

&lt;p&gt;So, there is IXSCAN and next FETCH with filter. Why filter is here?&lt;/p&gt;

&lt;p&gt;This is explain for&#160;db.getCollection(&apos;test&apos;).find({status: 1}, {}).count():&lt;br/&gt;
 &quot;queryHash&quot; : &quot;E6304EB6&quot;,&lt;br/&gt;
 &quot;planCacheKey&quot; : &quot;7A94191B&quot;,&lt;br/&gt;
 &quot;winningPlan&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;FETCH&quot;,&lt;br/&gt;
 &quot;inputStage&quot; : {&lt;br/&gt;
 &quot;stage&quot; : &quot;IXSCAN&quot;,&lt;br/&gt;
 &quot;keyPattern&quot; : &lt;/p&gt;
{
 &quot;status&quot; : 1.0
 }
&lt;p&gt;,&lt;br/&gt;
 &quot;indexName&quot; : &quot;status_1&quot;,&lt;br/&gt;
 &quot;isMultiKey&quot; : false,&lt;br/&gt;
 &quot;multiKeyPaths&quot; : &lt;/p&gt;
{
 &quot;status&quot; : []
 }
&lt;p&gt;,&lt;br/&gt;
 &quot;isUnique&quot; : false,&lt;br/&gt;
 &quot;isSparse&quot; : false,&lt;br/&gt;
 &quot;isPartial&quot; : false,&lt;br/&gt;
 &quot;indexVersion&quot; : 2,&lt;br/&gt;
 &quot;direction&quot; : &quot;forward&quot;,&lt;br/&gt;
 &quot;indexBounds&quot; : &lt;/p&gt;
{
 &quot;status&quot; : [ 
 &quot;[1.0, 1.0]&quot;
 ]}
&lt;p&gt;}},&lt;/p&gt;

&lt;p&gt;As you can see, there are no filter in FETCH, and this query is faster.&lt;br/&gt;
I tried it in cloud.mongodb.com&#160;on 4.2.10.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1540983">SERVER-52845</key>
            <summary>$exists works slowly</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="-1">Unassigned</assignee>
                                    <reporter username="dmitriy.aganov@gmail.com">&#1044;&#1084;&#1080;&#1090;&#1088;&#1080;&#1081; &#1040;&#1075;&#1072;&#1085;&#1086;&#1074;</reporter>
                        <labels>
                    </labels>
                <created>Fri, 13 Nov 2020 03:38:53 +0000</created>
                <updated>Fri, 13 Nov 2020 17:39:01 +0000</updated>
                            <resolved>Fri, 13 Nov 2020 17:39:00 +0000</resolved>
                                    <version>4.2.10</version>
                                                    <component>Index Maintenance</component>
                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="3489730" author="eric.sedor" created="Fri, 13 Nov 2020 17:38:36 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=dmitriy.aganov%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;dmitriy.aganov@gmail.com&quot;&gt;dmitriy.aganov@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-12869&quot; title=&quot;Index null values and missing values differently&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-12869&quot;&gt;SERVER-12869&lt;/a&gt; describes an improvement that will help with the performance difference you are observing. Please watch that ticket for updates and comment there if you see anything you&apos;d like to add.&lt;/p&gt;

&lt;p&gt;Thank you,&lt;br/&gt;
Eric&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="114107">SERVER-12869</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>Fri, 13 Nov 2020 17:38:36 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        3 years, 12 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>eric.sedor@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            3 years, 12 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>eric.sedor@mongodb.com</customfieldvalue>
            <customfieldvalue>dmitriy.aganov@gmail.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hyh6wv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hy38wf:</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;db.test.insertMany([&lt;/p&gt;
{&quot;name&quot; : &quot;0_0&quot;, &quot;status&quot; : 2.0 }
&lt;p&gt;,&lt;/p&gt;
{&quot;name&quot; : &quot;0_1&quot;, &quot;status&quot; : 2.0 }
&lt;p&gt;,&lt;/p&gt;
{&quot;name&quot; : &quot;0_2&quot;}
&lt;p&gt;,&lt;/p&gt;
{&quot;name&quot; : &quot;0_3&quot;, &quot;status&quot; : 2.0}
&lt;p&gt;,&lt;/p&gt;
{&quot;name&quot; : &quot;0_4&quot;}
&lt;p&gt;,&lt;/p&gt;
{&quot;name&quot; : &quot;0_5&quot;}
&lt;p&gt;,&lt;/p&gt;
{&quot;name&quot; : &quot;0_6&quot;, &quot;status&quot; : 2.0}
&lt;p&gt;,&lt;/p&gt;
{&quot;name&quot; : &quot;0_7&quot;, &quot;status&quot; : 3.0}
&lt;p&gt;]);&lt;/p&gt;

&lt;p&gt;db.test.createIndex({ status: 1});&lt;/p&gt;

&lt;p&gt;db.test.find({status: 2}, {}).explain();&lt;/p&gt;

&lt;p&gt;db.test.find({status: {$exists: false}}, {}).explain();&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>
                                

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

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