<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:48:43 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-18777] CachedPlanStage replanning mechanism does not apply to rooted $or queries</title>
                <link>https://jira.mongodb.org/browse/SERVER-18777</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Rooted $or queries run through the SubplanStage path. The SubplanStage may use a cached plan for a branch of the $or without making use of the CachedPlanStage trial period logic. This means that rooted $or queries could use badly performing plans without plan cache entry eviction and replanning kicking in.&lt;/p&gt;</description>
                <environment></environment>
        <key id="207697">SERVER-18777</key>
            <summary>CachedPlanStage replanning mechanism does not apply to rooted $or queries</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="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-optimization">Backlog - Query Optimization</assignee>
                                    <reporter username="david.storch@mongodb.com">David Storch</reporter>
                        <labels>
                            <label>bonsai</label>
                            <label>storch</label>
                    </labels>
                <created>Mon, 1 Jun 2015 15:47:09 +0000</created>
                <updated>Fri, 7 Apr 2023 13:26:22 +0000</updated>
                                                                            <component>Querying</component>
                                        <votes>4</votes>
                                    <watches>32</watches>
                                                                                                                <comments>
                            <comment id="1778236" author="justin.seyster" created="Thu, 18 Jan 2018 20:15:05 +0000"  >&lt;p&gt;I created a branch with the &lt;a href=&quot;https://github.com/mongodb/mongo/compare/master...jseyster:index-for-large-updates-poc?expand=1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;most recent POC&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="1772840" author="ian@10gen.com" created="Fri, 12 Jan 2018 16:11:11 +0000"  >&lt;p&gt;Dave to talk to Justin about pausing work on this for now and picking up the POC work done so far later in this release.&lt;/p&gt;</comment>
                            <comment id="1685107" author="david.storch" created="Fri, 29 Sep 2017 13:28:48 +0000"  >&lt;p&gt;Assigning to &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=justin.seyster&quot; class=&quot;user-hover&quot; rel=&quot;justin.seyster&quot;&gt;justin.seyster&lt;/a&gt; tentatively to explore possible fixes and the engineering complexity associated with any potential fix.&lt;/p&gt;</comment>
                            <comment id="999813" author="rassi@10gen.com" created="Fri, 7 Aug 2015 20:51:38 +0000"  >&lt;p&gt;To correct the zero-result/tying plans regression for the subplanner introduced in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-15225&quot; title=&quot;CachedPlanStage should execute for trial period and re-plan if query performs poorly&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-15225&quot;&gt;&lt;del&gt;SERVER-15225&lt;/del&gt;&lt;/a&gt;, we will implement &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-19835&quot; title=&quot;SubplanStage should not cache plan for an individual $or branch if plans tie or there are no query results&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-19835&quot;&gt;&lt;del&gt;SERVER-19835&lt;/del&gt;&lt;/a&gt; as an interim fix.  Bumping this ticket out of &quot;3.1 Required&quot; accordingly.&lt;/p&gt;

&lt;p&gt;The outstanding problem remains that subplanned queries are not able to make use of replanning.  Possible solutions:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;implement a per-branch trial period in the subplanner, and always throw out the results from the trial period (note: causes the initial work for each branch to unnecessarily be performed twice).&lt;/li&gt;
	&lt;li&gt;change the OR stage to &quot;round-robin&quot; on its children, revert the subplanner back to whole-query caching instead of per-branch caching, and replan from scratch if the trial period on the whole &quot;franken-plan&quot; does not perform well.&lt;/li&gt;
&lt;/ol&gt;
</comment>
                            <comment id="966656" author="david.storch" created="Wed, 15 Jul 2015 14:12:26 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=evan%40dnanexus.com&quot; class=&quot;user-hover&quot; rel=&quot;evan@dnanexus.com&quot;&gt;evan@dnanexus.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Sorry to hear that mongod is using a slow plan. Since the query&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;   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;db.data.find({id: $in: [&quot;object-1234&quot;, &quot;object-2345&quot;]}).sort({modified: 1, id: 1})&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;does not have an &lt;tt&gt;$or&lt;/tt&gt;, the problem you are experiencing is unrelated to this ticket. (The MongoDB query engine currently treats &lt;tt&gt;$or&lt;/tt&gt; and &lt;tt&gt;$in&lt;/tt&gt; differently; see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-12024&quot; title=&quot;re-implement $in in terms of $or&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-12024&quot;&gt;SERVER-12024&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;After reviewing the information you provided, I would suggest looking at &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-15225&quot; title=&quot;CachedPlanStage should execute for trial period and re-plan if query performs poorly&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-15225&quot;&gt;&lt;del&gt;SERVER-15225&lt;/del&gt;&lt;/a&gt;. Under this ticket, we added functionality which can prevent bad plan selections like this one. This functionality is first available in version 3.0.4 and is enabled by the &lt;tt&gt;internalQueryCacheReplanningEnabled&lt;/tt&gt; flag. Please refer to &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-15225&quot; title=&quot;CachedPlanStage should execute for trial period and re-plan if query performs poorly&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-15225&quot;&gt;&lt;del&gt;SERVER-15225&lt;/del&gt;&lt;/a&gt; for more details.&lt;/p&gt;

&lt;p&gt;Also, keep in mind that &lt;a href=&quot;http://docs.mongodb.org/manual/reference/method/cursor.hint/#cursor.hint&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;.hint()&lt;/a&gt; and &lt;a href=&quot;http://docs.mongodb.org/manual/core/query-plans/#index-filters&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;index filters&lt;/a&gt; are always available as workarounds if the server is choosing a slow plan.&lt;/p&gt;

&lt;p&gt;Best,&lt;br/&gt;
Dave&lt;/p&gt;</comment>
                            <comment id="966376" author="evan@dnanexus.com" created="Wed, 15 Jul 2015 05:43:06 +0000"  >&lt;p&gt;Hi Dan, I&apos;m happy to help explain what we are seeing. I&apos;ve left out many details that I don&apos;t think are relevant, but let me know if you&apos;d like to know more.&lt;/p&gt;

&lt;p&gt;Collection: &quot;data&quot;&lt;br/&gt;
Number of documents: 15,000,000&lt;/p&gt;

&lt;p&gt;Every data object has an &quot;id&quot; and a &quot;modified&quot; field.&lt;/p&gt;

&lt;p&gt;Indexes&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;{id: 1}&lt;/li&gt;
	&lt;li&gt;{modified: 1, id: 1}&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Now take a query 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;   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;db.data.find({id: $in: [&quot;object-1234&quot;, &quot;object-2345&quot;]}).sort({modified: 1, id: 1})&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;Most of the time is takes 100ms, using the id index. For some reason, every once in a while, it uses the modified_1_id_1 index and takes 30 minutes. We have no idea why this happens.&lt;/p&gt;

&lt;p&gt;I realize my query is not a rooted $or, but it seems related to poor query plan caching..&lt;/p&gt;</comment>
                            <comment id="966359" author="dan@10gen.com" created="Wed, 15 Jul 2015 03:50:27 +0000"  >&lt;p&gt;Hi Evan, Can you lay out your example use case which is hitting this particular issue in more detail?&lt;/p&gt;</comment>
                            <comment id="966237" author="evan@dnanexus.com" created="Tue, 14 Jul 2015 23:03:16 +0000"  >&lt;p&gt;Is there any workaround for this issue? Ever since upgrading to Mongo 2.6.9 we randomly see rooted $or queries which use an index which performs terribly. If the right index is used, the query takes 100ms. If the wrong index is used, it takes 30 minutes...&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="224733">SERVER-19835</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="133270">SERVER-13732</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="157798">SERVER-15225</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>8.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25126"><![CDATA[Query Optimization]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[500A000000XMnT2IAL, 5002K00000kEujaQAC, 5002K00000odd1lQAA]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 14 Jul 2015 23:03:16 +0000</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            6 years, 3 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>backlog-query-optimization</customfieldvalue>
            <customfieldvalue>dan@mongodb.com</customfieldvalue>
            <customfieldvalue>david.storch@mongodb.com</customfieldvalue>
            <customfieldvalue>evan@dnanexus.com</customfieldvalue>
            <customfieldvalue>ian@mongodb.com</customfieldvalue>
            <customfieldvalue>rassi</customfieldvalue>
            <customfieldvalue>justin.seyster@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrl4bz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr2ljj:</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_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="1924">Query 2017-10-23</customfieldvalue>
    <customfieldvalue id="1952">Query 2017-11-13</customfieldvalue>
    <customfieldvalue id="1979">Query 2017-12-04</customfieldvalue>
    <customfieldvalue id="2034">Query 2017-12-18</customfieldvalue>
    <customfieldvalue id="2076">Query 2018-01-01</customfieldvalue>
    <customfieldvalue id="2077">Query 2018-01-15</customfieldvalue>

                        </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|hsfz3r:</customfieldvalue>

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