<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:47: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>[SERVER-18426] $geoNear expands aggressively if the centroid is far from the dense data</title>
                <link>https://jira.mongodb.org/browse/SERVER-18426</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I have a collection with 300,000 documents. In collection there is a 2dsphere index on &apos;geo&apos; field.&lt;/p&gt;

&lt;p&gt;Here is a query I run:&lt;br/&gt;
db.runCommand(&lt;/p&gt;
{ 
    geoNear: &quot;around_test&quot;, 
    near: [59.6048899000000030, 36.2774393999999990], 
    num: 500,
    spherical:true, 
    query: null,
}
&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;Stats of this query are weird:&lt;br/&gt;
stats: &lt;/p&gt;
{
    &quot;nscanned&quot; : 103971,
    &quot;objectsLoaded&quot; : 80166,
    &quot;avgDistance&quot; : 0.1816846648955057,
    &quot;maxDistance&quot; : 0.1955302102158397,
    &quot;time&quot; : 1124
}

&lt;p&gt;In the query I limit results to 500 documents. But in stats I see that mongoDB reads 80166 (objectsLoaded) documents from disk and only then cuts it out.&lt;br/&gt;
No need to read extra documents from disk if there is a limit on result length.&lt;/p&gt;</description>
                <environment></environment>
        <key id="203518">SERVER-18426</key>
            <summary>$geoNear expands aggressively if the centroid is far from the dense data</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="backlog-query-integration">Backlog - Query Integration</assignee>
                                    <reporter username="andrey.hohutkin@gmail.com">Andrey Hohutkin</reporter>
                        <labels>
                            <label>qi-geo</label>
                            <label>query-44-grooming</label>
                    </labels>
                <created>Tue, 12 May 2015 07:35:52 +0000</created>
                <updated>Thu, 4 Jan 2024 14:02:28 +0000</updated>
                                            <version>3.0.2</version>
                                                    <component>Geo</component>
                                        <votes>0</votes>
                                    <watches>16</watches>
                                                                                                                <comments>
                            <comment id="988593" author="siyuan.zhou@10gen.com" created="Fri, 24 Jul 2015 20:17:19 +0000"  >&lt;p&gt;As &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=brandon.zhang&quot; class=&quot;user-hover&quot; rel=&quot;brandon.zhang&quot;&gt;brandon.zhang&lt;/a&gt; explained above, this is different from &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-18056&quot; title=&quot;2d nearSphere performance regression&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-18056&quot;&gt;&lt;del&gt;SERVER-18056&lt;/del&gt;&lt;/a&gt; as the centroid is far from the dense data. I&apos;ll update the title and reopen this issue.&lt;/p&gt;</comment>
                            <comment id="988142" author="brandon.zhang" created="Fri, 24 Jul 2015 14:15:21 +0000"  >&lt;p&gt;This behavior is due to the way geoNear expands its search. geoNear works by searching for documents in distance intervals successively farther from the centroid. At each interval, it will sort the documents by distance and return them to its parent stage. If the number of documents returned in an interval is less than 300, the next distance interval will double its range. &lt;br/&gt;
The explain produced by this query will show the distance intervals and the number of documents returned in each one:&lt;br/&gt;
db.around_test.find({geo:{$nearSphere:&lt;span class=&quot;error&quot;&gt;&amp;#91;59.6048899000000030, 36.2774393999999990&amp;#93;&lt;/span&gt;}}).limit(500).explain(&quot;executionStats&quot;)&lt;br/&gt;
In this case, the centroid of the geoNear search seems to be far from a dense patch of points. Before the last interval, every interval that geoNear searched returned less than 300 documents. This means that the distance intervals kept doubling until it hit the dense patch, which returned over 80,000 documents. Unfortunately, there is currently no way for geoNear to account for this problem since it has no prior knowledge of the data distribution.&lt;/p&gt;</comment>
                            <comment id="919503" author="samk" created="Wed, 20 May 2015 18:27:22 +0000"  >&lt;p&gt;Thanks for this report. &lt;/p&gt;

&lt;p&gt;Because geoNear returns sorted results, it starts from the geometry (i.e. point) specified in the query and selects all points that exist within a radius of the starting point. The operation sorts results, and if the result set requires additional results, it fetches all documents within a larger additional covering (a donut shaped surface). Because of the way that the geo indexes work, its possible for the query to fetch and examine the same document more than once during a single query.&lt;/p&gt;

&lt;p&gt;We were able to reproduce your results, and while this behavior and performance that is not desirable, it is expected given the current implementation. The work defined by &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-18056&quot; title=&quot;2d nearSphere performance regression&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-18056&quot;&gt;&lt;del&gt;SERVER-18056&lt;/del&gt;&lt;/a&gt; should improve this behavior. As a result we are going to close this ticket, please tune in to &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-18506&quot; title=&quot;Balancer section of printShardingStatus should respect passed-in configDB&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-18506&quot;&gt;&lt;del&gt;SERVER-18506&lt;/del&gt;&lt;/a&gt; for updates.&lt;/p&gt;

&lt;p&gt;Regards,&lt;br/&gt;
sam&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="383821">SERVER-29228</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="330866">SERVER-26974</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="73867" name="around_test.7z" size="3864515" author="andrey.hohutkin@gmail.com" created="Tue, 12 May 2015 07:35:52 +0000"/>
                    </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_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25467"><![CDATA[Query Integration]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 20 May 2015 18:27:22 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            8 years, 29 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>andrey.hohutkin@gmail.com</customfieldvalue>
            <customfieldvalue>backlog-query-integration</customfieldvalue>
            <customfieldvalue>brandon.zhang</customfieldvalue>
            <customfieldvalue>sam.kleinman</customfieldvalue>
            <customfieldvalue>siyuan.zhou@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrl687:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr2frz:</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_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|hsg1j3:</customfieldvalue>

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