<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:42 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>[JAVA-193] perf slowdown when slaveOk() is set on the DB or Query object and then performing cursor.itcount()</title>
                <link>https://jira.mongodb.org/browse/JAVA-193</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Problem:&lt;br/&gt;
Seeing a large perf difference when the SlaveOk() is set (DB or cursor), e.g.&lt;/p&gt;

&lt;p&gt;cur = coll.find(query).limit(20).addOption(Bytes.QUERYOPTION_SLAVEOK);&lt;/p&gt;

&lt;p&gt;and then performing&lt;/p&gt;

&lt;p&gt;count = cur.itcount()&lt;/p&gt;

&lt;p&gt;Without SlaveOk()&lt;br/&gt;
Inserting data :&lt;br/&gt;
Querying data :&lt;br/&gt;
Queries : 121002&lt;br/&gt;
Rows found : 2420040&lt;br/&gt;
Finished :&lt;/p&gt;


&lt;p&gt;With SlaveOk()&lt;br/&gt;
Inserting data :&lt;br/&gt;
Querying data :&lt;br/&gt;
Queries : 181&lt;br/&gt;
Rows found : 3620&lt;br/&gt;
Finished :&lt;/p&gt;

&lt;p&gt;Reproduce:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;create a two node replset&lt;/li&gt;
	&lt;li&gt;compile attached java code&lt;br/&gt;
javac -classpath mongo-2.2.jar SlaveTest.java &lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;run without SalveOk()&lt;br/&gt;
java -cp mongo-2.2.jar SlaveTest &quot;localhost:27000,localhost:27001&quot; test blogs 0 1&lt;/li&gt;
&lt;/ul&gt;


&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;run with slaveOk()&lt;br/&gt;
&quot;localhost:27000,localhost:27001,localhost:27002&quot; test blogs 2 1&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Business Case:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;performance&lt;/li&gt;
&lt;/ul&gt;

</description>
                <environment></environment>
        <key id="13415">JAVA-193</key>
            <summary>perf slowdown when slaveOk() is set on the DB or Query object and then performing cursor.itcount()</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="eliot">Eliot Horowitz</assignee>
                                    <reporter username="alvin">Alvin Richards</reporter>
                        <labels>
                    </labels>
                <created>Mon, 18 Oct 2010 19:47:59 +0000</created>
                <updated>Fri, 29 Oct 2010 02:48:53 +0000</updated>
                            <resolved>Wed, 20 Oct 2010 05:13:30 +0000</resolved>
                                    <version>2.2</version>
                                    <fixVersion>2.3</fixVersion>
                                    <component>Performance</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="19533" author="josephykwang" created="Fri, 22 Oct 2010 22:41:06 +0000"  >&lt;p&gt;we see this problem running java 2.2 driver against mongodb-linux-x86_64-1.6.3.&lt;/p&gt;</comment>
                            <comment id="19380" author="eliot" created="Wed, 20 Oct 2010 05:13:30 +0000"  >&lt;p&gt;Not sure which other case fixed this - but the difference was 2.2 and head&lt;/p&gt;</comment>
                            <comment id="19345" author="alvin" created="Tue, 19 Oct 2010 16:57:38 +0000"  >&lt;p&gt;   ./software/mongodb-osx-x86_64-1.7.1/bin/mongod --fork --dbpath /data/db/db1 --port 27000 --replSet fred/ &lt;br/&gt;
   ./software/mongodb-osx-x86_64-1.7.1/bin/mongod --fork --dbpath /data/db/db2 --port 27001 --replSet fred/localhost:27000 &lt;br/&gt;
   ./software/mongodb-osx-x86_64-1.7.1/bin/mongod --fork --dbpath /data/db/db3 --port 27002 --replSet fred/localhost:27000 &lt;/p&gt;

&lt;p&gt;using 1.7.1&lt;/p&gt;

</comment>
                            <comment id="19337" author="eliot" created="Tue, 19 Oct 2010 06:41:55 +0000"  >&lt;p&gt;Also what version of mongod&lt;/p&gt;</comment>
                            <comment id="19336" author="eliot" created="Tue, 19 Oct 2010 06:39:49 +0000"  >&lt;p&gt;That&apos;s irrelavent - will find all nods when it starts.&lt;/p&gt;

&lt;p&gt;How are you starting the mongod?&lt;/p&gt;</comment>
                            <comment id="19334" author="alvin" created="Tue, 19 Oct 2010 06:32:48 +0000"  >&lt;p&gt;Looks like you just have a single host as a parameter. Just re-ran&lt;/p&gt;

&lt;p&gt;&quot;localhost:27000,localhost:27002&quot; scaleout blogs 0 1&lt;/p&gt;

&lt;p&gt;Inserting data :&lt;br/&gt;
Querying data :&lt;br/&gt;
Queries : 116517&lt;br/&gt;
Rows found : 2330340&lt;br/&gt;
Finished :&lt;/p&gt;

&lt;p&gt;&quot;localhost:27000,localhost:27002&quot; scaleout blogs 2 1&lt;/p&gt;

&lt;p&gt;Inserting data :&lt;br/&gt;
Querying data :&lt;br/&gt;
Queries : 181&lt;br/&gt;
Rows found : 3620&lt;br/&gt;
Finished :&lt;/p&gt;</comment>
                            <comment id="19331" author="eliot" created="Tue, 19 Oct 2010 06:19:53 +0000"  >&lt;p&gt;Can&apos;t seem to reproduce&lt;/p&gt;

&lt;p&gt;$ javac SlaveTest2.java &amp;amp;&amp;amp; java SlaveTest2 localhost:27017 test foo 0 1&lt;br/&gt;
Inserting data :&lt;br/&gt;
Querying data :&lt;br/&gt;
Queries : 120465&lt;br/&gt;
Rows found : 2409300&lt;br/&gt;
Finished :&lt;br/&gt;
$ javac SlaveTest2.java &amp;amp;&amp;amp; java SlaveTest2 localhost:27017 test foo 2 1&lt;br/&gt;
Inserting data :&lt;br/&gt;
Querying data :&lt;br/&gt;
Queries : 123037&lt;br/&gt;
Rows found : 2460740&lt;br/&gt;
Finished :&lt;/p&gt;</comment>
                            <comment id="19308" author="alvin" created="Mon, 18 Oct 2010 20:04:46 +0000"  >&lt;p&gt;Workaround:&lt;/p&gt;

&lt;p&gt;cursor.itcount() is really meant for testing purposes only, it iterates through the cursor. If you need a count which takes into account the limit/skip use size().&lt;/p&gt;

&lt;p&gt;For the same data, size() gives the following perf numbers&lt;/p&gt;

&lt;p&gt;Inserting data :&lt;br/&gt;
Querying data :&lt;br/&gt;
Queries : 325430&lt;br/&gt;
Rows found : 6508600&lt;br/&gt;
Finished :&lt;/p&gt;


</comment>
                    </comments>
                    <attachments>
                            <attachment id="10517" name="SlaveTest.java" size="2453" author="alvin" created="Mon, 18 Oct 2010 19:48:29 +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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhcq7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14862</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>