<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:07:48 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-5063] $in on first compound key element and limit efficiency</title>
                <link>https://jira.mongodb.org/browse/SERVER-5063</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;If you have an index on ( a , b ) and do a query like find( { a : &lt;/p&gt;
{ $in : [ ... }
&lt;p&gt; } ).sort( &lt;/p&gt;
{ b : 1 }
&lt;p&gt; ).limit(10)&lt;br/&gt;
an easy optimization is limiting the results for each $in element to the limit.&lt;/p&gt;</description>
                <environment></environment>
        <key id="31432">SERVER-5063</key>
            <summary>$in on first compound key element and limit efficiency</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="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="9">Done</resolution>
                                        <assignee username="aaron">Aaron Staple</assignee>
                                    <reporter username="eliot">Eliot Horowitz</reporter>
                        <labels>
                    </labels>
                <created>Fri, 24 Feb 2012 05:58:22 +0000</created>
                <updated>Wed, 28 Oct 2015 04:26:21 +0000</updated>
                            <resolved>Mon, 9 Apr 2012 20:59:09 +0000</resolved>
                                                    <fixVersion>2.1.1</fixVersion>
                                    <component>Querying</component>
                                        <votes>2</votes>
                                    <watches>8</watches>
                                                                                                                <comments>
                            <comment id="138327" author="aaron" created="Sat, 30 Jun 2012 18:38:47 +0000"  >&lt;p&gt;Hi Artur,&lt;/p&gt;

&lt;p&gt;No problem.  It looks like your &apos;feelings_1_location.state_1_created_at_-1&apos; index is multikey, which would explain why the optimization is not being used.  (It is not supported for multikey indexes.)&lt;/p&gt;</comment>
                            <comment id="138293" author="arturhoo" created="Sat, 30 Jun 2012 14:58:12 +0000"  >&lt;p&gt;Hi Aaron,&lt;/p&gt;

&lt;p&gt;Thanks for your prompt reply. Please find the information you asked for: &lt;br/&gt;
v2.0.6&lt;br/&gt;
&lt;a href=&quot;http://pastie.org/private/dhsoanhnzlvgtkx71o9nq&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://pastie.org/private/dhsoanhnzlvgtkx71o9nq&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;v2.1.2&lt;br/&gt;
&lt;a href=&quot;http://pastie.org/private/0a33rnyxxqeukdwbevurw&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://pastie.org/private/0a33rnyxxqeukdwbevurw&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Indeed, as you said, v2.1 is reporting the nscanned values of all candidates. My fault for not reading the changelog throughly. &lt;/p&gt;

&lt;p&gt;Anyways, I was expecting a performance boost in v2.1 for this specific query given the compound index, but I think I&apos;ll have to wait until &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-3310&quot; title=&quot;Query optimizer should efficiently handle $in and sort with compound index.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-3310&quot;&gt;&lt;del&gt;SERVER-3310&lt;/del&gt;&lt;/a&gt; is solved.&lt;/p&gt;

&lt;p&gt;Thank you once again!&lt;/p&gt;</comment>
                            <comment id="138239" author="aaron" created="Sat, 30 Jun 2012 03:27:54 +0000"  >&lt;p&gt;Hi Artur,&lt;/p&gt;

&lt;p&gt;I think you may be encountering a difference the explain behavior between 2.0 and 2.1.  In 2.1 the nscanned reported for the overall query includes the nscanned values of all candidate plans attempted.  In 2.0 only the nscanned of the &quot;winning&quot; query plan is reported.&lt;/p&gt;

&lt;p&gt;Could you please send the output of:&lt;/p&gt;

&lt;p&gt;db.dev06.find( ... ).explain( true )&lt;br/&gt;
db.dev06.find( ... ).hint( &lt;/p&gt;
{ feelings:1, &apos;location.state&apos;:1, created_at:-1 }
&lt;p&gt; ).explain( true )&lt;/p&gt;

&lt;p&gt;for both 2.0 and 2.1?  Also, it would be helpful for clarity if you could include the command you enter into the shell with the shell output you post.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Aaron&lt;/p&gt;</comment>
                            <comment id="138237" author="arturhoo" created="Sat, 30 Jun 2012 02:48:42 +0000"  >&lt;p&gt;I would just like to share my experience, where I have the following indexes:&lt;/p&gt;

&lt;p&gt;&quot;indexSizes&quot; : {&lt;br/&gt;
	&quot;&lt;em&gt;id&lt;/em&gt;&quot; : 9026304,&lt;br/&gt;
	&quot;created_at_-1&quot; : 6344576,&lt;br/&gt;
	&quot;feelings_1_location.state_1_created_at_-1&quot; : 10285408&lt;br/&gt;
},&lt;/p&gt;

&lt;p&gt;The query:&lt;br/&gt;
db.dev06.find({&lt;br/&gt;
    &apos;feelings&apos;: &lt;/p&gt;
{
        $in: [
            &apos;cansado&apos;,
            &apos;triste&apos;
        ]
    }
&lt;p&gt;,&lt;br/&gt;
    &apos;location.state&apos; : &lt;/p&gt;
{
        $in: [
            &apos;Minas Gerais&apos;,
            &apos;Rio de Janeiro&apos;
        ]
    }
&lt;p&gt;}).sort(&lt;/p&gt;
{&apos;created_at&apos;: -1}
&lt;p&gt;).limit(10).explain();&lt;/p&gt;

&lt;p&gt;In v2.0.6 the results were:&lt;br/&gt;
&lt;a href=&quot;http://pastie.org/private/frfkmfuli7uqi6fwiykag&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://pastie.org/private/frfkmfuli7uqi6fwiykag&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;while in v2.1.2 there was a significant increase in the number of objects scanned:&lt;br/&gt;
&lt;a href=&quot;http://pastie.org/private/6dtbsxb6vofzh8yslmicca&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://pastie.org/private/6dtbsxb6vofzh8yslmicca&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even if I hint in v.2.0.6 the same index used in v2.1.2, it still scans less documents:&lt;br/&gt;
&lt;a href=&quot;http://pastie.org/private/ejgiavgf1reqlq5hwhgpw&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://pastie.org/private/ejgiavgf1reqlq5hwhgpw&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="108069" author="aaron" created="Mon, 9 Apr 2012 22:36:20 +0000"  >&lt;p&gt;Hi James,&lt;/p&gt;

&lt;p&gt;The performance improvement you&apos;ll see will be very dependent on your data distribution, and it&apos;s possible to generate a benchmark with an arbitrary improvement multiple by varying the amount of data in your test.  (For example I just ran a simple test for this optimization that showed a four order of magnitude performance improvement.)&lt;/p&gt;

&lt;p&gt;Is there a real world example data set you&apos;d like to test?&lt;/p&gt;</comment>
                            <comment id="108050" author="foobar2k" created="Mon, 9 Apr 2012 21:46:42 +0000"  >&lt;p&gt;Out of interest, what was the speed difference for $in queries of this type after this change, do you have any benchmark results?&lt;/p&gt;</comment>
                            <comment id="107595" author="auto" created="Sat, 7 Apr 2012 17:07:22 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;astaple&apos;, u&apos;name&apos;: u&apos;Aaron&apos;, u&apos;email&apos;: u&apos;aaron@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5063&quot; title=&quot;$in on first compound key element and limit efficiency&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5063&quot;&gt;&lt;del&gt;SERVER-5063&lt;/del&gt;&lt;/a&gt; $in limit efficiency.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/7cacde89bb37051549b38abaf4d6b591b199b243&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/7cacde89bb37051549b38abaf4d6b591b199b243&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="18552">SERVER-3310</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="35320">SERVER-5481</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="37982">SERVER-5777</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="35032">SERVER-5450</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="43093">SERVER-6268</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>7.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 3 Apr 2012 20:53:35 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 33 weeks, 4 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>aaron</customfieldvalue>
            <customfieldvalue>arturhoo</customfieldvalue>
            <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>foobar2k</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrociv:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7978</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_10166" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Tests Written</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10154"><![CDATA[Complete]]></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|hstb3r:</customfieldvalue>

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