<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:38:02 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>[GODRIVER-2194] `CountDocuments` slowly</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-2194</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;use `CountDocuments` to get count is slowly than useing mongoshell, By looking log of mongodb, it seems like `CountDocuments` will use `aggregate` to compute count.&lt;/p&gt;

&lt;p&gt;mongoshell spend 1660ms,&#160;`CountDocuments` spend 2436ms. the filter count is 349326,&#160; the collection count is 19492668, and i have created index.&lt;/p&gt;

&lt;p&gt;Are there any way to improve the performance?&lt;/p&gt;</description>
                <environment></environment>
        <key id="1903002">GODRIVER-2194</key>
            <summary>`CountDocuments` slowly</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="13203">Gone away</resolution>
                                        <assignee username="benji.rewis@mongodb.com">Benji Rewis</assignee>
                                    <reporter username="mrliuxiansen8023@gmail.com">du liu</reporter>
                        <labels>
                    </labels>
                <created>Wed, 20 Oct 2021 06:53:14 +0000</created>
                <updated>Fri, 27 Oct 2023 20:01:14 +0000</updated>
                            <resolved>Thu, 28 Oct 2021 15:49:15 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4156691" author="JIRAUSER1253736" created="Fri, 29 Oct 2021 10:10:26 +0000"  >&lt;p&gt;mongodb server: 3.2.21&lt;/p&gt;

&lt;p&gt;Esha Bhargava (Jira) &amp;lt;jira@mongodb.org&amp;gt; &#20110;2021&#24180;10&#26376;26&#26085;&#21608;&#20108; &#19978;&#21320;3:47&#20889;&#36947;&#65306;&lt;/p&gt;

&lt;p&gt;&amp;gt; Esha Bhargava&lt;br/&gt;
&amp;gt; &amp;lt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=esha.bhargava&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/secure/ViewProfile.jspa?name=esha.bhargava&lt;/a&gt;&amp;gt;&lt;br/&gt;
&amp;gt; &lt;b&gt;updated&lt;/b&gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;image: Improvement&amp;#93;&lt;/span&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2194&quot; title=&quot;`CountDocuments` slowly&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-2194&quot;&gt;&lt;del&gt;GODRIVER-2194&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&amp;gt; &amp;lt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2194&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/GODRIVER-2194&lt;/a&gt;&amp;gt;&lt;br/&gt;
&amp;gt;&lt;br/&gt;
&amp;gt; Go Driver &amp;lt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/GODRIVER&lt;/a&gt;&amp;gt; / [image:&lt;br/&gt;
&amp;gt; Improvement] &amp;lt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2194&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/GODRIVER-2194&lt;/a&gt;&amp;gt; &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2194&quot; title=&quot;`CountDocuments` slowly&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-2194&quot;&gt;&lt;del&gt;GODRIVER-2194&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&amp;gt; &amp;lt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2194&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/GODRIVER-2194&lt;/a&gt;&amp;gt;&lt;br/&gt;
&amp;gt; `CountDocuments` slowly &amp;lt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2194&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/GODRIVER-2194&lt;/a&gt;&amp;gt;&lt;br/&gt;
&amp;gt; Change By: Esha Bhargava&lt;br/&gt;
&amp;gt; &amp;lt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=esha.bhargava&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/secure/ViewProfile.jspa?name=esha.bhargava&lt;/a&gt;&amp;gt;&lt;br/&gt;
&amp;gt; Assignee: Benji Rewis&lt;br/&gt;
&amp;gt; Status: Needs Triage Investigating&lt;br/&gt;
&amp;gt; &lt;span class=&quot;error&quot;&gt;&amp;#91;image: Add Comment&amp;#93;&lt;/span&gt;&lt;br/&gt;
&amp;gt; &amp;lt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2194#add-comment&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/GODRIVER-2194#add-comment&lt;/a&gt;&amp;gt; Add Comment&lt;br/&gt;
&amp;gt; &amp;lt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2194#add-comment&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/GODRIVER-2194#add-comment&lt;/a&gt;&amp;gt;&lt;br/&gt;
&amp;gt;&lt;br/&gt;
&amp;gt; This message was sent from MongoDB&apos;s issue tracking system. To respond to&lt;br/&gt;
&amp;gt; this ticket, please login to jira.mongodb.org using your JIRA, MongoDB&lt;br/&gt;
&amp;gt; Cloud Manager, or MongoDB Atlas credentials.&lt;br/&gt;
&amp;gt;&lt;/p&gt;</comment>
                            <comment id="4154814" author="benji.rewis" created="Thu, 28 Oct 2021 15:49:01 +0000"  >&lt;p&gt;Happy to help (sounds like my suggestions did not do much haha). I&apos;m curious why upgrading to 4.4 made the count operation so much faster. I&apos;ll close this ticket as &quot;gone away&quot; for now, but out of curiosity, which MongoDB server version did you upgrade from?&lt;/p&gt;</comment>
                            <comment id="4153581" author="JIRAUSER1253736" created="Thu, 28 Oct 2021 05:43:51 +0000"  >&lt;p&gt;Thanks! I tried it yesterday.(Only faster a litter&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/sad.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;) Then I give up and upgrade mongo server to 4.4.5.&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/wink.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;,faster so much!&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/biggrin.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;

&lt;p&gt;Thank you!&lt;/p&gt;</comment>
                            <comment id="4152162" author="benji.rewis" created="Wed, 27 Oct 2021 17:01:37 +0000"  >&lt;p&gt;An excellent point; &lt;tt&gt;Cursor.All&lt;/tt&gt; will certainly take a lot of memory locally, especially with the amount of documents you have. If you&apos;d like to maintain the performance of &lt;tt&gt;db.collection.find({filter}).count()&lt;/tt&gt;, your best bet may be to manually run a &lt;tt&gt;count&lt;/tt&gt; command using &lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/blob/master/mongo/database.go#L192&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;RunCommand&lt;/tt&gt;&lt;/a&gt;. I&apos;ve attached a file containing example code for how you might do that.&lt;/p&gt;

&lt;p&gt;Note that this is exactly what the driver does when running &lt;tt&gt;EstimatedDocumentCount&lt;/tt&gt; against server versions &amp;lt;= 4.9.0.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/attachment/342750/342750_count_example.go&quot; title=&quot;count_example.go attached to GODRIVER-2194&quot;&gt;count_example.go&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;https://jira.mongodb.org/images/icons/link_attachment_7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</comment>
                            <comment id="4150390" author="JIRAUSER1253736" created="Wed, 27 Oct 2021 03:22:14 +0000"  >&lt;p&gt;It seems like&#160; `Cursor.All` will be more slowly and will take more memory...&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/sad.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                            <comment id="4150371" author="JIRAUSER1253736" created="Wed, 27 Oct 2021 02:41:23 +0000"  >&lt;p&gt;Thanks&lt;/p&gt;</comment>
                            <comment id="4149115" author="benji.rewis" created="Tue, 26 Oct 2021 18:05:47 +0000"  >&lt;p&gt;Gotcha; that makes sense.&lt;/p&gt;

&lt;p&gt;There is unfortunately no one operation in the Go driver that is a perfect analogue of &lt;tt&gt;db.collection.find({filter}).count()&lt;/tt&gt;. You could run something like&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;cursor, err := coll.Find(context.TODO(), {my filter})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;if err != nil {   &lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   panic(err)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&amp;nbsp;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;var docs []bson.D&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;err = cursor.All(context.TODO(), &amp;amp;docs)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;if err != nil {   &lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   panic(err)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&amp;nbsp;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;count := len(docs)&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;That code would probably have similar performance to &lt;tt&gt;db.collection.find({filter}).count()&lt;/tt&gt;. &lt;a href=&quot;https://docs.mongodb.com/manual/reference/method/db.collection.countDocuments/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;db.collection.countDocuments&lt;/a&gt; (and its analogue in the Go driver &lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/blob/master/mongo/collection.go#L870&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;CountDocuments&lt;/a&gt;) &lt;em&gt;will&lt;/em&gt; return a more accurate count (even after an unclean shutdown or in the presence of orphaned documents on sharded clusters).&lt;/p&gt;

&lt;p&gt;Adding an operation in the Go driver equivalent to&#160;&lt;tt&gt;db.collection.find({filter}).count()&lt;/tt&gt; (or modifying &lt;tt&gt;CountDocuments&lt;/tt&gt; to use the code above) would require a cross-drivers change. Drivers already &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst#count-api-details&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;agreed&lt;/a&gt; to deprecate our version of &lt;tt&gt;db.collection.count()&lt;/tt&gt;, so that change seems unlikely to me. That said, I&apos;m happy to bring it up with the drivers department as a whole.&lt;/p&gt;</comment>
                            <comment id="4147276" author="JIRAUSER1253736" created="Tue, 26 Oct 2021 04:38:41 +0000"  >&lt;p&gt;Thanks for your replay. I want to count by a query filter.So I can not use&#160;&#160;&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/blob/master/mongo/collection.go#L954&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;EstimatedDocumentCount .&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And in the mognoshell, my query like this: db.collection.find({my filter}).count()&lt;/p&gt;</comment>
                            <comment id="4146578" author="benji.rewis" created="Mon, 25 Oct 2021 20:16:22 +0000"  >&lt;p&gt;Hello &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=mrliuxiansen8023%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;mrliuxiansen8023@gmail.com&quot;&gt;mrliuxiansen8023@gmail.com&lt;/a&gt;! Thanks for your improvement suggestion.&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;CountDocuments&lt;/tt&gt; does indeed run an &lt;tt&gt;aggregate&lt;/tt&gt; under the hood. The mongoshell&apos;s &lt;a href=&quot;https://docs.mongodb.com/manual/reference/method/db.collection.countDocuments/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;db.collection.countDocuments&lt;/a&gt; actually runs the exact same &lt;tt&gt;aggregate&lt;/tt&gt;, so there really shouldn&apos;t be a significant difference in performance.&lt;/p&gt;

&lt;p&gt;Which mongoshell operation are you running? &lt;a href=&quot;https://docs.mongodb.com/manual/reference/method/db.collection.count/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;db.collection.count&lt;/a&gt; is a slightly different mongoshell method with better performance that only returns an approximate count. If you only need an approximate account you can always use &lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/blob/master/mongo/collection.go#L954&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;EstimatedDocumentCount&lt;/a&gt; in the Go driver. EstimatedDocumentCount should have much better performance, as it does not perform an entire collection scan.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="342750" name="count_example.go" size="850" author="benji.rewis@mongodb.com" created="Wed, 27 Oct 2021 17:01:17 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10257" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Documentation Changes</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="11861"><![CDATA[Not Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hzq5lr:</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>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>