<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:35:14 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-14557] querying with hashed borders broke in 2.6</title>
                <link>https://jira.mongodb.org/browse/SERVER-14557</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;It was possible in 2.4 to query a sharded collection by hashedkey with hashed borders like this:&lt;/p&gt;

&lt;p&gt;db.collection.find(&lt;br/&gt;
{ &quot;_id&quot; : &lt;/p&gt;
{ &quot;$gte&quot; : -9219144072535768301, 
             &quot;$lt&quot; : -9214747938866076750}
&lt;p&gt;}).hint(&lt;/p&gt;
{ &quot;_id&quot; : &quot;hashed&quot;}
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;The range values are chunk borders.&lt;br/&gt;
This query returns all documents from this chunk only asking one shard.&lt;br/&gt;
Moving to MongoDB 2.6 this stopped working.&lt;/p&gt;

&lt;p&gt;An explain returns BtreeCursor but scannedObjects is indication a whole table scan on all shards.&lt;br/&gt;
Additionally it shows wrong indexBounds:&lt;/p&gt;

&lt;p&gt; &quot;_id&quot; : [&lt;br/&gt;
                    [&lt;br/&gt;
                        &lt;/p&gt;
{
                            &quot;$minElement&quot; : 1
                        }
&lt;p&gt;,&lt;/p&gt;
                        {
                            &quot;$maxElement&quot; : 1
                        }
&lt;p&gt;                    ]&lt;br/&gt;
                ]&lt;/p&gt;

&lt;p&gt;The same problem arises in mongoDB&apos;s own hadoop connector when using hashed sharded collections. (&lt;a href=&quot;https://github.com/mongodb/mongo-hadoop&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-hadoop&lt;/a&gt;)&lt;/p&gt;</description>
                <environment></environment>
        <key id="147209">SERVER-14557</key>
            <summary>querying with hashed borders broke in 2.6</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="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="breitlauch">Daniel Breitlauch</reporter>
                        <labels>
                    </labels>
                <created>Tue, 15 Jul 2014 13:04:15 +0000</created>
                <updated>Wed, 10 Dec 2014 23:10:23 +0000</updated>
                            <resolved>Tue, 15 Jul 2014 20:41:11 +0000</resolved>
                                    <version>2.6.0</version>
                    <version>2.6.1</version>
                    <version>2.6.2</version>
                    <version>2.6.3</version>
                                                    <component>Querying</component>
                    <component>Sharding</component>
                                        <votes>3</votes>
                                    <watches>10</watches>
                                                                                                                <comments>
                            <comment id="660501" author="rassi@10gen.com" created="Wed, 16 Jul 2014 13:59:00 +0000"  >&lt;p&gt;That is a known issue.  See &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14400&quot; title=&quot;Using $min and $max on shard key doesn&amp;#39;t target queries&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14400&quot;&gt;SERVER-14400&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="660370" author="breitlauch" created="Wed, 16 Jul 2014 10:12:45 +0000"  >&lt;p&gt;Thanks a lot!&lt;br/&gt;
It works.&lt;/p&gt;

&lt;p&gt;Although while testing I encountered some strange behavior.&lt;br/&gt;
I queried with the chunk borders like this:&lt;br/&gt;
db.test.find()&lt;br/&gt;
    .min(&lt;/p&gt;
{ _id : -6148914691236517204}
&lt;p&gt;)&lt;br/&gt;
    .max(&lt;/p&gt;
{ _id : -3074457345618258602}
&lt;p&gt;)&lt;br/&gt;
    .hint({_id : &quot;hashed&quot;})&lt;br/&gt;
.explain()&lt;/p&gt;

&lt;p&gt;The explain shows correctly all documents fetched from one shard but:&lt;br/&gt;
    &quot;n&quot; : 9,&lt;br/&gt;
    &quot;nscanned&quot; : 12,&lt;br/&gt;
    &quot;nscannedAllPlans&quot; : 12,&lt;br/&gt;
    &quot;nscannedObjects&quot; : 9,&lt;br/&gt;
    &quot;nscannedObjectsAllPlans&quot; : 9,&lt;br/&gt;
    &quot;numQueries&quot; : 3,&lt;br/&gt;
    &quot;numShards&quot; : 3,&lt;/p&gt;

&lt;p&gt;shows that all 3 shards got queried. The 2 other shards without documents do have:&lt;br/&gt;
   &quot;nscannedObjects&quot; : 0,&lt;br/&gt;
                &quot;nscanned&quot; : 1,&lt;/p&gt;

&lt;p&gt;Why does the switch issues queries to all shards?&lt;/p&gt;</comment>
                            <comment id="659407" author="greg_10gen" created="Tue, 15 Jul 2014 15:21:15 +0000"  >&lt;p&gt;This was broken behavior in v2.4 that unfortunately happened to work in this case - query operators apply to the document data itself, not the index keys.&lt;/p&gt;

&lt;p&gt;In order to do chunk range queries over shard keys (which are themselves index keys), you&apos;ll want to use the .min()/.max() cursor methods with .hint().  These methods accept the (potentially hashed) index keys, not document values, and will do what you want (including doing the right thing for compound shard keys, which won&apos;t work with $gt/$lt).&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://docs.mongodb.org/manual/reference/method/cursor.min/#cursor.min&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://docs.mongodb.org/manual/reference/method/cursor.min/#cursor.min&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                                        </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 15 Jul 2014 14:34:03 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            9 years, 31 weeks 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>breitlauch</customfieldvalue>
            <customfieldvalue>greg_10gen</customfieldvalue>
            <customfieldvalue>rassi</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrlrpr:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>127404</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;1. Create sharded collection with shardkey as hashed _id.&lt;br/&gt;
2. Fill with whatever&lt;br/&gt;
3. Lookup one chunks borders&lt;br/&gt;
4. Query like this for all documents in that chunk:&lt;/p&gt;

&lt;p&gt;db.collection.find(&lt;br/&gt;
{ &quot;_id&quot; : &lt;/p&gt;
{ &quot;$gte&quot; : -9219144072535768301, 
             &quot;$lt&quot; : -9214747938866076750}
&lt;p&gt;}).hint(&lt;/p&gt;
{ &quot;_id&quot; : &quot;hashed&quot;}
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;Behavior in 2.4: Query to one shard and use of index there.&lt;br/&gt;
Behavior in 2.6: Very slow table scan on all shards&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|hrrbx3:</customfieldvalue>

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