<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:56:53 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-1392] Strange geolocation query slowness</title>
                <link>https://jira.mongodb.org/browse/SERVER-1392</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I&apos;m noticing huge disparities between some geolocation queries. The queries don&apos;t seem all that different, yet there is a huge difference in time taken to complete them--as in, some reliably finish in under a second, while others reliably take seconds or more. See, for instance, this session:&lt;/p&gt;

&lt;p&gt;MongoDB shell version: 1.5.5-pre-&lt;/p&gt;

&lt;p&gt;connecting to: hermes&lt;/p&gt;

&lt;p&gt;&amp;gt; db.nodes.find({ loc: { $within: { $box: [ &lt;/p&gt;
{ lat: 30.29714, lon: -97.73608 }
&lt;p&gt;&amp;lt;ithin: { $box: [ &lt;/p&gt;
{ lat: 30.29714, lon: -97.73608 }
&lt;p&gt;,                          &lt;/p&gt;
{ lat: 30.29914, lon: -9

&amp;lt;.29714, lon: -97.73608 }
&lt;p&gt;, &lt;/p&gt;
{ lat: 30.29914, lon: -97                         .73408000000001 }
&lt;p&gt; ] } } }&lt;/p&gt;

&lt;p&gt;&amp;lt;&lt;/p&gt;
{ lat: 30.29914, lon: -97.73408000000001 }
&lt;p&gt; ] } } })                         .explain()&lt;/p&gt;

{

	&quot;cursor&quot; : &quot;GeoBrowse-box&quot;,

	&quot;nscanned&quot; : 5,

	&quot;nscannedObjects&quot; : 5,

	&quot;n&quot; : 5,

	&quot;millis&quot; : 5021,

	&quot;indexBounds&quot; : [ ]

}

&lt;p&gt;&amp;gt; &lt;/p&gt;

&lt;p&gt;&amp;gt; &lt;br/&gt;
&amp;lt;29914, lon: -97.73408000000001 } ] } } }).explain()&lt;/p&gt;

{

	&quot;cursor&quot; : &quot;GeoBrowse-box&quot;,

	&quot;nscanned&quot; : 5,

	&quot;nscannedObjects&quot; : 5,

	&quot;n&quot; : 5,

	&quot;millis&quot; : 5434,

	&quot;indexBounds&quot; : [ ]

}

&lt;p&gt;&amp;gt; &lt;br/&gt;
&amp;lt;29914, lon: -97.73408000000001 } ] } } }).explain()&lt;/p&gt;

{

	&quot;cursor&quot; : &quot;GeoBrowse-box&quot;,

	&quot;nscanned&quot; : 5,

	&quot;nscannedObjects&quot; : 5,

	&quot;n&quot; : 5,

	&quot;millis&quot; : 5516,

	&quot;indexBounds&quot; : [ ]

}

&lt;p&gt;&amp;gt; db.nodes.find({ loc: { $within: { $box: [ &lt;/p&gt;
{ lat: 30.29664, lon: -97.7364 }
&lt;p&gt;,&lt;br/&gt;
&amp;lt;ithin: { $box: [ &lt;/p&gt;
{ lat: 30.29664, lon: -97.7364 }
&lt;p&gt;,                          &lt;/p&gt;
{ lat: 30.29864, lon: -97

&amp;lt;.29664, lon: -97.7364 }
&lt;p&gt;, &lt;/p&gt;
{ lat: 30.29864, lon: -97.                         73439999999999 }
&lt;p&gt; ] } } })&lt;/p&gt;

&lt;p&gt;&amp;lt; lat: 30.29864, lon: -97.73439999999999 } ] } } }).                         explain()&lt;/p&gt;

{

	&quot;cursor&quot; : &quot;GeoBrowse-box&quot;,

	&quot;nscanned&quot; : 6,

	&quot;nscannedObjects&quot; : 6,

	&quot;n&quot; : 6,

	&quot;millis&quot; : 562,

	&quot;indexBounds&quot; : [ ]

}

&lt;p&gt;&amp;gt; &lt;br/&gt;
&amp;lt;29864, lon: -97.73439999999999 } ] } } }).explain()&lt;/p&gt;

{

	&quot;cursor&quot; : &quot;GeoBrowse-box&quot;,

	&quot;nscanned&quot; : 6,

	&quot;nscannedObjects&quot; : 6,

	&quot;n&quot; : 6,

	&quot;millis&quot; : 559,

	&quot;indexBounds&quot; : [ ]

}

&lt;p&gt;&amp;gt; &lt;br/&gt;
&amp;lt;29864, lon: -97.73439999999999 } ] } } }).explain()&lt;/p&gt;

{

	&quot;cursor&quot; : &quot;GeoBrowse-box&quot;,

	&quot;nscanned&quot; : 6,

	&quot;nscannedObjects&quot; : 6,

	&quot;n&quot; : 6,

	&quot;millis&quot; : 563,

	&quot;indexBounds&quot; : [ ]

}


&lt;p&gt;It appears that the second query scans and returns more objects, yet it takes a tenth the amount of time. Note that the first query takes ten times longer to return, but this is actually short. I&apos;ve had queries that took upwards of 30 seconds to return similar results.&lt;/p&gt;

&lt;p&gt;None of these areas are sparsely populated with points, so I don&apos;t think that the issue is that the query distances need to be limited.&lt;/p&gt;

&lt;p&gt;You can find my dataset here: &lt;a href=&quot;http://dl.dropbox.com/u/147071/dump.tar.bz2&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://dl.dropbox.com/u/147071/dump.tar.bz2&lt;/a&gt; It&apos;s 293M, and I apologize for that, but I don&apos;t know what specific aspects of my data may be causing this disparity in search times. Dropbox says that the file will finish uploading in an hour or so.&lt;/p&gt;

&lt;p&gt;Also, because the above transcript didn&apos;t paste in such that the queries are cut-and-paste-friendly, here are the two that I am trying, slow query first:&lt;/p&gt;

&lt;p&gt;db.nodes.find({ loc: { $within: { $box: [ &lt;/p&gt;
{ lat: 30.29714, lon: -97.73608 }
&lt;p&gt;, &lt;/p&gt;
{ lat: 30.29914, lon: -97.73408000000001 }
&lt;p&gt; ] } } }).explain()&lt;/p&gt;

&lt;p&gt;db.nodes.find({ loc: { $within: { $box: [ &lt;/p&gt;
{ lat: 30.29664, lon: -97.7364 }
&lt;p&gt;, &lt;/p&gt;
{ lat: 30.29864, lon: -97.73439999999999 }
&lt;p&gt; ] } } }).explain()&lt;/p&gt;</description>
                <environment>Linux</environment>
        <key id="12403">SERVER-1392</key>
            <summary>Strange geolocation query slowness</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="mathias@mongodb.com">Mathias Stearn</assignee>
                                    <reporter username="nolan">Nolan Darilek</reporter>
                        <labels>
                    </labels>
                <created>Sat, 10 Jul 2010 12:05:22 +0000</created>
                <updated>Tue, 12 Jul 2016 00:30:00 +0000</updated>
                            <resolved>Mon, 18 Oct 2010 18:29:34 +0000</resolved>
                                    <version>1.5.4</version>
                                    <fixVersion>1.6.4</fixVersion>
                    <fixVersion>1.7.2</fixVersion>
                                    <component>Geo</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="19431" author="railsjedi" created="Thu, 21 Oct 2010 08:32:46 +0000"  >&lt;p&gt;Working pretty awesome. Thanks for the backport!&lt;/p&gt;</comment>
                            <comment id="19427" author="redbeard0531" created="Wed, 20 Oct 2010 23:11:12 +0000"  >&lt;p&gt;Backport done&lt;/p&gt;</comment>
                            <comment id="19426" author="auto" created="Wed, 20 Oct 2010 23:10:51 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;login&apos;: &apos;RedBeard0531&apos;, &apos;name&apos;: &apos;Mathias Stearn&apos;, &apos;email&apos;: &apos;mathias@10gen.com&apos;}
&lt;p&gt;Message: Faster $box queries &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1392&quot; title=&quot;Strange geolocation query slowness&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1392&quot;&gt;&lt;del&gt;SERVER-1392&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo/commit/8d79226466632ca8a57a3b140cf3b0f0f2e60f19&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo/commit/8d79226466632ca8a57a3b140cf3b0f0f2e60f19&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="19372" author="railsjedi" created="Wed, 20 Oct 2010 02:20:52 +0000"  >&lt;p&gt;This patch seems to apply cleanly to 1.6 branch. Any chance of a backport for a 1.6.x release?&lt;/p&gt;
</comment>
                            <comment id="19297" author="auto" created="Mon, 18 Oct 2010 18:29:18 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;login&apos;: &apos;RedBeard0531&apos;, &apos;name&apos;: &apos;Mathias Stearn&apos;, &apos;email&apos;: &apos;mathias@10gen.com&apos;}
&lt;p&gt;Message: Faster $box queries &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1392&quot; title=&quot;Strange geolocation query slowness&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1392&quot;&gt;&lt;del&gt;SERVER-1392&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo/commit/b902ee404623407ba3eca55954882afbe389f9aa&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo/commit/b902ee404623407ba3eca55954882afbe389f9aa&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="15881" author="richard@10gen.com" created="Fri, 16 Jul 2010 15:21:09 +0000"  >&lt;p&gt;AFAICT, there are 3 things going on here, but you&apos;re sort of running into limitations in the geospatial search algorithm we&apos;re using.&lt;/p&gt;

&lt;p&gt;First, geohashing has the property that superficially similar queries will end up examining different boxes within the coordinate space.  The faster query scans the rectangle with corners (30.2948, -97.7399), (30.3003, -97.7344), while the slower is scanning the rectangle with corners (29.5312, -98.4375), (30.9375, -97.0313).&lt;/p&gt;

&lt;p&gt;Next, because geospatial search examines every point inside these boxes to see whether the points are inside the query box, if the data set is relatively dense, that makes for a lot of searching.  This data set is fairly dense.&lt;/p&gt;

&lt;p&gt;Finally, it turns out that explain() reports meaningless numbers of documents visited during a search.  It turns out that the fast query (the one that scans the smaller box) visits 900K documents, while the slow query (the one that scans the bigger bounding box) visits 8M documents.  That explain() is misleading is a bug; I&apos;ve crated a case:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://jira.mongodb.org/browse/SERVER-1429&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;http://jira.mongodb.org/browse/SERVER-1429&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, the performance profile you&apos;re experiencing is mostly a property of geohashing.&lt;/p&gt;</comment>
                            <comment id="15878" author="richard@10gen.com" created="Fri, 16 Jul 2010 14:28:14 +0000"  >&lt;p&gt;Visualization of the data set.  18.9 million points here.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="10293" name="server-1392.png" size="5337" author="richard.kreuter" created="Fri, 16 Jul 2010 14:28:14 +0000"/>
                    </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>Fri, 16 Jul 2010 14:28:14 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            13 years, 17 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10020"><![CDATA[Linux]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>railsjedi</customfieldvalue>
            <customfieldvalue>mathias@mongodb.com</customfieldvalue>
            <customfieldvalue>nolan</customfieldvalue>
            <customfieldvalue>richard.kreuter</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrpjt3:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>22071</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_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|ht0hsn:</customfieldvalue>

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