<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:10:03 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-5848] Refactor IndexType suitability() method to take a FieldRangeSetPair</title>
                <link>https://jira.mongodb.org/browse/SERVER-5848</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Background:&lt;/p&gt;

&lt;p&gt;When mongo runs a query (or count, update, etc...) the query optimizer will iterate over all indexes in the collection and check each to see if a query plan using that index should be considered to evaluate the query.  There are two steps in the process:&lt;/p&gt;

&lt;p&gt;1) The index&apos;s IndexSpec is checked for its &quot;suitability.&quot;  If suitability() is USELESS, the index will be ignored, otherwise the implementation proceeds to step #2.  For non btree indexes, IndexSpec::suitability() will delegate to IndexType::suitability().  This allows non btree index types to implement their own suitability behaviors (there is a different IndexType implementation per type of index).  For example, 2d indexes and hashed indexes implement custom suitability methods.&lt;/p&gt;

&lt;p&gt;2) The query optimizer creates a QueryPlan based on the query and index.  This QueryPlan has a &quot;utility&quot; which currently implements more precise checks than IndexSpec::suiitability().  Depending on the &quot;utility&quot; values for the different candidate QueryPlans, one or more of these QueryPlans will be put in a QueryPlanSet and used to execute the query.&lt;/p&gt;

&lt;p&gt;Functional Overview:&lt;/p&gt;

&lt;p&gt;This ticket represents changing the suitability() interface function from:&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;virtual IndexSuitability suitability( const BSONObj&amp;amp; query , const BSONObj&amp;amp; order ) const ;&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;to&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;virtual IndexSuitability suitability( const FieldRangeSet&amp;amp; queryConstraints, const BSONObj&amp;amp; order ) const;&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;A FieldRangeSet is a representation of a parsed query that describes the bounds on all query fields suitable for indexing.  Passing this representation to suitability() allows the different suitability() implementations to access this index bound information without re-parsing the query.  A FieldRangeSet also normalizes the information about a query that is pertinent in this context, for example &lt;/p&gt;
{ a:1 }
&lt;p&gt; and { $and:[ &lt;/p&gt;
{ a:1 }
&lt;p&gt; ] } produce the same FieldRangeSet.&lt;/p&gt;

&lt;p&gt;The primary functional change is that passing a FieldRangeSet instead of a bson query allows the hash index implementation to utilize queries consisting of a set of equality values (for example, { a:&lt;/p&gt;
{ $in:[ 1, 2 ] }
&lt;p&gt; }) which was not possible previously.  (Previously, the &apos;query&apos; parameter passed to suitability() was a simplified form of the original query and not precise enough for the hashed index implementation to identify such cases.)&lt;/p&gt;

&lt;p&gt;Aside from this primary functional change, the different IndexType::suitability() implementations have been updated.  In addition the IndexSpec::_suitability() implementation (for btree indexes) has been updated and its behavior changed slightly as described in the comment preceding the new code.  Also, the code that passes arguments to suitability() has been updated slightly.  It may be worth testing the updated suitability() implementations as part of the qa effort.&lt;/p&gt;

&lt;p&gt;Aaron&lt;/p&gt;

&lt;p&gt;-----------------------------&lt;/p&gt;

&lt;p&gt;The IndexType suitability() method should takes an already parsed query, instead of a raw query.  This will save the cost of re-parsing complicated queries for every candidate index. For our purposes, a parsed query is represented as a &quot;FieldRangeSetPair,&quot; so the input to suitability() should be one of these instead of a BSONObj.  &lt;/p&gt;

&lt;p&gt;This will also fix a problem with hashed indexes not being used for certain queries (like $in queries) due to the suitability method being passed an oversimplified query.  &lt;/p&gt;</description>
                <environment></environment>
        <key id="38769">SERVER-5848</key>
            <summary>Refactor IndexType suitability() method to take a FieldRangeSetPair</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="matulef">Kevin Matulef</assignee>
                                    <reporter username="matulef">Kevin Matulef</reporter>
                        <labels>
                    </labels>
                <created>Tue, 15 May 2012 17:15:09 +0000</created>
                <updated>Mon, 11 Jul 2016 18:32:41 +0000</updated>
                            <resolved>Thu, 20 Dec 2012 21:30:42 +0000</resolved>
                                    <version>2.1.1</version>
                                    <fixVersion>2.3.2</fixVersion>
                                    <component>Index Maintenance</component>
                    <component>Querying</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="290294" author="auto" created="Fri, 15 Mar 2013 17:45:32 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2013-03-15T15:19:59Z&apos;, u&apos;name&apos;: u&apos;aaron&apos;, u&apos;email&apos;: u&apos;aaron@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5848&quot; title=&quot;Refactor IndexType suitability() method to take a FieldRangeSetPair&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5848&quot;&gt;&lt;del&gt;SERVER-5848&lt;/del&gt;&lt;/a&gt; Additional tests.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/4c75c66c34bae94e61e805403ceca4e132856064&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/4c75c66c34bae94e61e805403ceca4e132856064&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="220687" author="auto" created="Thu, 20 Dec 2012 21:28:56 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-12-20T21:25:57Z&apos;, u&apos;email&apos;: u&apos;matulef@10gen.com&apos;, u&apos;name&apos;: u&apos;Kevin Matulef&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5848&quot; title=&quot;Refactor IndexType suitability() method to take a FieldRangeSetPair&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5848&quot;&gt;&lt;del&gt;SERVER-5848&lt;/del&gt;&lt;/a&gt; further simplifications to default suitability() method&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/429d1a8f670a6f29975f16a1465044f677656bd5&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/429d1a8f670a6f29975f16a1465044f677656bd5&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="218485" author="auto" created="Tue, 18 Dec 2012 18:22:09 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-12-18T18:17:34Z&apos;, u&apos;email&apos;: u&apos;matulef@10gen.com&apos;, u&apos;name&apos;: u&apos;Kevin Matulef&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5848&quot; title=&quot;Refactor IndexType suitability() method to take a FieldRangeSetPair&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5848&quot;&gt;&lt;del&gt;SERVER-5848&lt;/del&gt;&lt;/a&gt; ammend c++ unit tests for new suitability method&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/0133fa6fe09720333bc0cd49fea6dba4f284edd5&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/0133fa6fe09720333bc0cd49fea6dba4f284edd5&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="218389" author="auto" created="Tue, 18 Dec 2012 16:38:47 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-12-18T16:35:36Z&apos;, u&apos;name&apos;: u&apos;Alberto Lerner&apos;, u&apos;email&apos;: u&apos;alerner@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5848&quot; title=&quot;Refactor IndexType suitability() method to take a FieldRangeSetPair&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5848&quot;&gt;&lt;del&gt;SERVER-5848&lt;/del&gt;&lt;/a&gt; Disable tests temporarily (fix compile).&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/95aec02bdeb20e4529c140464996b8b47d9dd7e8&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/95aec02bdeb20e4529c140464996b8b47d9dd7e8&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="218356" author="auto" created="Tue, 18 Dec 2012 16:01:58 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;date&apos;: u&apos;2012-12-18T15:54:41Z&apos;, u&apos;name&apos;: u&apos;Kevin Matulef&apos;, u&apos;email&apos;: u&apos;matulef@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5848&quot; title=&quot;Refactor IndexType suitability() method to take a FieldRangeSetPair&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5848&quot;&gt;&lt;del&gt;SERVER-5848&lt;/del&gt;&lt;/a&gt; determine index suitability using a FieldRangeSet&lt;/p&gt;

&lt;p&gt;Previously each special index type would determine the suitability&lt;br/&gt;
of the index by analyzing the original query.  To avoid re-parsing&lt;br/&gt;
the query for each index, we now pass in a FieldRangeSet, which is&lt;br/&gt;
a better representation of all the constraints implied by the query.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/6b46f885aba062ffcddbd6f7cfb2a36e23bbce1d&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/6b46f885aba062ffcddbd6f7cfb2a36e23bbce1d&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="38932">SERVER-5858</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>5.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 15 May 2012 17:18:36 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        10 years, 48 weeks, 5 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>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            10 years, 48 weeks, 5 days 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>auto</customfieldvalue>
            <customfieldvalue>matulef</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hro2x3:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>5684</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_10166" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Tests Written</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10153"><![CDATA[Unneeded]]></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|hrkyyf:</customfieldvalue>

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