<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:58:09 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-21697] Plan ranking should take query and index keys into consideration for breaking ties</title>
                <link>https://jira.mongodb.org/browse/SERVER-21697</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;In situation where there are two plans that tie, if one matches more (leading?) keys in the query than another then it&apos;s more likely to be a better plan for other queries of this shape.&lt;/p&gt;

&lt;p&gt;Example:&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;db.collection.find({a:999, b:111, c:&quot;x&quot;}).sort({d:-1})&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;// indexes for collection:&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;{a:1,b:1,c:1,d:1}&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;{a:1,b:1,d:1}&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;   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;{a:1,d: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;For value of a in query that matches one or no documents all three indexes are going to perform equally (yes?) - we should break the tie in favor of the first one because it matches the most predicate fields in the query.&lt;/p&gt;</description>
                <environment></environment>
        <key id="241455">SERVER-21697</key>
            <summary>Plan ranking should take query and index keys into consideration for breaking ties</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="3">Duplicate</resolution>
                                        <assignee username="backlog-query-optimization">Backlog - Query Optimization</assignee>
                                    <reporter username="asya.kamsky@mongodb.com">Asya Kamsky</reporter>
                        <labels>
                            <label>bonsai</label>
                            <label>storch</label>
                    </labels>
                <created>Mon, 30 Nov 2015 17:49:46 +0000</created>
                <updated>Mon, 11 Sep 2023 10:37:41 +0000</updated>
                            <resolved>Mon, 11 Sep 2023 10:37:40 +0000</resolved>
                                                                    <component>Querying</component>
                                        <votes>8</votes>
                                    <watches>29</watches>
                                                                                                                <comments>
                            <comment id="5693231" author="JIRAUSER1261429" created="Mon, 11 Sep 2023 10:37:41 +0000"  >&lt;p&gt;The fix was implemented in PM-3316 via &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-80233&quot; title=&quot;Implement index prefix heuristic&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-80233&quot;&gt;&lt;del&gt;SERVER-80233&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="2273207" author="bartle" created="Wed, 5 Jun 2019 21:34:26 +0000"  >&lt;p&gt;As a concrete example, you can imagine that it&apos;s pretty common to shard collections based on a &quot;user&quot; or &quot;account&quot; key, and have ~all queries/indexes start with this &quot;user&quot; key.  For an email messages collection with indexes {user: 1, sent_time: -1} and {user: 1, recipient: 1}, a query on user+recipient might perform equally well on both indexes (i.e. tie) for a particular user (imagine a user that only sends emails to a single recipient) or recipient (perhaps the given recipient was simply the most recently emailed), but not others.&lt;/p&gt;

&lt;p&gt;In practice, we&apos;ve found that such sub-optimal plans will often make a query that might normally take 1-2 ms take 100&apos;s of ms or even 10&apos;s of seconds to execute; in the worst case, a sub-optimal plan might require scanning all documents for a given &quot;user&quot;.  As a result, we generally require all queries to be hinted.  This is doable for queries that are statically defined, but is much harder for queries that are dynamically constructed.&lt;/p&gt;</comment>
                            <comment id="2272969" author="david.storch" created="Wed, 5 Jun 2019 19:35:08 +0000"  >&lt;p&gt;In &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-40844&quot; title=&quot;Better tie breaking of &amp;quot;perfect&amp;quot; indexes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-40844&quot;&gt;&lt;del&gt;SERVER-40844&lt;/del&gt;&lt;/a&gt;, &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=bartle%40stripe.com&quot; class=&quot;user-hover&quot; rel=&quot;bartle@stripe.com&quot;&gt;bartle@stripe.com&lt;/a&gt; suggests implementing a simple version of this behavior where there is a scoring bonus associated with a &quot;perfect&quot; match. That is, in the case of a tie between two single-index plans, prefer the plan where the set of paths over which there are equality predicates is identical to the set of paths in the index. For instance, if there are equality predicates on &quot;a&quot;, &quot;b&quot;, and &quot;c&quot;, prefer index {c: 1, a: 1, b: 1} over either {a: 1, b: 1} or {a: 1, b: 1, z: 1}. Implementing this safely could be challenging, since the order of the index key pattern is important and may affect the performance of the plan.&lt;/p&gt;</comment>
                            <comment id="1761059" author="asya" created="Thu, 28 Dec 2017 21:05:52 +0000"  >&lt;p&gt;Somewhat related to &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-20616&quot; title=&quot;Plan ranker sampling from the beginning of a query&amp;#39;s execution can result in poor plan selection&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-20616&quot;&gt;SERVER-20616&lt;/a&gt; since taking full predicate vs indexed fields into account in cases of ties can tip the odds to an index more likely to be more selective (in other scenarios than the one being raced).&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="1850847">SERVER-59337</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="2420825">SERVER-80233</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="745541">SERVER-40844</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="120781">SERVER-13211</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.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[[5002K00000e98g5QAA, 5002K00000gm1k1QAA, 5002K00000kE9UoQAK, 5002K00000ll0vFQAQ, 5002K00000mqZjkQAE, 5002K00000tTFpeQAG, 5002K00000tVCvbQAG, 5002K00000uDSmJQAW, 5002K00000yTWVwQAO, 5002K00000zdrhAQAQ, 5002K00000zdP4lQAE, 5006R00001l9uNwQAI, 5006R00001mtBShQAM, 5006R00001m6kCXQAY, 5006R00001m6xBLQAY, 5002K000011CaExQAK, 5006R00001nLXMpQAO, 5006R00001m8VrtQAE, 5006R00001r7JjNQAU, 5006R00001r8xsZQAQ, 5006R00001sC0xpQAC]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 5 Jun 2019 19:35:08 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        21 weeks, 2 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[<s><a href='https://jira.mongodb.org/browse/TSEXP-1758'>TSEXP-1758</a></s>]]></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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-3316</customfieldvalue>
                        </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>alexander.ignatyev@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            21 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>alexander.ignatyev@mongodb.com</customfieldvalue>
            <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>backlog-query-optimization</customfieldvalue>
            <customfieldvalue>bartle</customfieldvalue>
            <customfieldvalue>david.storch@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrknfr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr2lj3:</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_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|hsfejr:</customfieldvalue>

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