<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:06:21 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-4565] Count() takes exceptionally long time/hangs</title>
                <link>https://jira.mongodb.org/browse/SERVER-4565</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Having a problem with following query:&lt;/p&gt;

&lt;p&gt;db.test.count({&quot;location&quot; : {&quot;$within&quot; : {&quot;$center&quot; : [[ -87, 41], 5]}}, &quot;initial_type&quot; : &quot;x&quot;})&lt;/p&gt;

&lt;p&gt;I built an index for geospatial and the above call type.  Coordinates are reduced for privacy reasons fyi...&lt;/p&gt;

&lt;p&gt;The find() returns exceptionally fast...but the count above just hangs.  Any quick thoughts?  thx&lt;/p&gt;</description>
                <environment>Red Hat Linux Enterprise</environment>
        <key id="27294">SERVER-4565</key>
            <summary>Count() takes exceptionally long time/hangs</summary>
                <type id="6" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14720&amp;avatarType=issuetype">Question</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="bill">Bill Hayward</assignee>
                                    <reporter username="brett.goldstein@cityofchicago.org">Brett Goldstein</reporter>
                        <labels>
                    </labels>
                <created>Tue, 27 Dec 2011 17:45:22 +0000</created>
                <updated>Thu, 6 Apr 2023 17:32:42 +0000</updated>
                            <resolved>Tue, 17 Jan 2012 12:40:16 +0000</resolved>
                                    <version>2.0.2</version>
                                                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="76362" author="richard@10gen.com" created="Wed, 28 Dec 2011 18:50:21 +0000"  >&lt;p&gt;Yes, please make a new issue for the separate topic.&lt;/p&gt;</comment>
                            <comment id="76309" author="brett.goldstein@cityofchicago.org" created="Wed, 28 Dec 2011 15:59:15 +0000"  >&lt;p&gt;i have some questions about faults....should i open a new thread?&lt;/p&gt;</comment>
                            <comment id="76307" author="brett.goldstein@cityofchicago.org" created="Wed, 28 Dec 2011 15:58:22 +0000"  >&lt;p&gt;got the diff between the count and find ...the issue was too much data within the search radius.&lt;/p&gt;

&lt;p&gt;what we are doing is lab testing mongodo to be the aggregation point of very large sets of disparate spatial data.  the intent would be to run a mapping layer on top to pass a coordinate, data para, radius to return everything in that area.  we may also layer on some real-time data...whether it goes to mongo first or comes from a geospatial SDE is TBD.  make sense?&lt;/p&gt;</comment>
                            <comment id="76304" author="richard@10gen.com" created="Wed, 28 Dec 2011 15:46:45 +0000"  >&lt;p&gt;@Brett: are you saying that find() returns a cursor immediately, or that iterating through all the documents that match is seemingly immediate?  The count and the query both traverse a subset of the index to see what documents match the query, but count has to do so immediately, whereas the query only steps through the index as the client requests documents from the server by iterating the cursor.  So if you&apos;re comparing the performance of &lt;/p&gt;

&lt;p&gt;var cnt = db.test.count(...);&lt;/p&gt;

&lt;p&gt;and &lt;/p&gt;

&lt;p&gt;var cur = db.test.find(...);&lt;/p&gt;

&lt;p&gt;then you&apos;re comparing very different things.&lt;/p&gt;

&lt;p&gt;Anyway, I&apos;m still curious what you&apos;re trying to do with this geo query.  To reiterate, that radius of 5 in the $within part of your query specifies a circle of about 300-350 miles around your center point.  That&apos;s a pretty big space, relatively speaking; how much of your data set falls within that area?&lt;/p&gt;</comment>
                            <comment id="76253" author="eliot" created="Wed, 28 Dec 2011 06:24:00 +0000"  >&lt;p&gt;Are these lat/long?&lt;br/&gt;
If so - 5 is very large - 300 miles or so.&lt;/p&gt;</comment>
                            <comment id="76200" author="brett.goldstein@cityofchicago.org" created="Tue, 27 Dec 2011 22:19:57 +0000"  >&lt;p&gt;ok...been playing with this.  find() returns almost instantly...and count() does not (and i am just adding .count() to the end of the query.  however, when i radically reduce the radius, the return improves dramatically.  my first move was from 5 -&amp;gt; 1 and that did not impact much.  However,moving from1 -&amp;gt; .001 has a 1 second return with count() = ~ 11k points.&lt;/p&gt;</comment>
                            <comment id="76181" author="richard@10gen.com" created="Tue, 27 Dec 2011 21:29:29 +0000"  >&lt;p&gt;Attempt to reproduce problem described, with randomly-generated data.  Possibly meaningless.&lt;/p&gt;</comment>
                            <comment id="76180" author="richard@10gen.com" created="Tue, 27 Dec 2011 21:28:37 +0000"  >&lt;p&gt;Have you compared how long it takes to iterate through all the documents that match the find() to how long it takes for count() to return?  In local testing (with a randomly generated data set but identical geospatial index), the count() takes a similar amount of time as iterating through all the documents from the find().&lt;/p&gt;

&lt;p&gt;(Additionally, note that the geo part of your query searches 5 degrees of arc over a hypothetical great circle on the earth, or about a 350 mile radius around &lt;span class=&quot;error&quot;&gt;&amp;#91;-87, 41&amp;#93;&lt;/span&gt;.  If you have a lot of points within that radius and if any specific value for initial_type is relatively sparsely distributed within that search space, the &quot;haystack&quot; index may be more suitable.  See:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.mongodb.org/display/DOCS/Geospatial+Haystack+Indexing&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.mongodb.org/display/DOCS/Geospatial+Haystack+Indexing&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But it&apos;s also possible that the geo search isn&apos;t necessary at all.  Could you say any more about what you&apos;re trying to find?) &lt;/p&gt;</comment>
                            <comment id="76174" author="brett.goldstein@cityofchicago.org" created="Tue, 27 Dec 2011 21:11:42 +0000"  >&lt;p&gt;originally when i first saw the count() issue it was 24 million...now 44808486&lt;/p&gt;</comment>
                            <comment id="76164" author="dwight_10gen" created="Tue, 27 Dec 2011 19:45:23 +0000"  >&lt;p&gt;what does db.test.count() return?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="14268" name="server-4565.js" size="1329" author="richard.kreuter" created="Tue, 27 Dec 2011 21:29:29 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>10.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 27 Dec 2011 19:45:23 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            12 years, 8 weeks 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>bill</customfieldvalue>
            <customfieldvalue>brett.goldstein@cityofchicago.org</customfieldvalue>
            <customfieldvalue>dwight@mongodb.com</customfieldvalue>
            <customfieldvalue>eliot</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|hroi9r:</customfieldvalue>

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

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

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