<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 07:38:53 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>[DOCS-523] Add additional information on query performance when using regular expressions.</title>
                <link>https://jira.mongodb.org/browse/DOCS-523</link>
                <project id="10380" key="DOCS">Documentation</project>
                    <description>&lt;p&gt;The documentation on indexing and query performance is incomplete with regard to how different regex queries perform, and does not cover the performance characteristics of queries containing multiple regex queries.&lt;/p&gt;</description>
                <environment></environment>
        <key id="50535">DOCS-523</key>
            <summary>Add additional information on query performance when using regular expressions.</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="kay.kim@mongodb.com">Kay Kim</assignee>
                                    <reporter username="william.zola@10gen.com">William Zola</reporter>
                        <labels>
                    </labels>
                <created>Fri, 14 Sep 2012 17:31:58 +0000</created>
                <updated>Thu, 28 Aug 2014 21:28:59 +0000</updated>
                            <resolved>Thu, 28 Aug 2014 21:28:59 +0000</resolved>
                                                    <fixVersion>v1.3.10</fixVersion>
                                    <component>manual</component>
                        <due></due>
                            <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="164549" author="william.zola@10gen.com" created="Fri, 14 Sep 2012 17:35:13 +0000"  >&lt;p&gt;The performance of multiple regexes depends on the index chosen to perform the query, and the exact fields used by the query.  &lt;/p&gt;

&lt;p&gt;Here are the rules:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;MongoDB dynamically chooses a query plan based on the real-time performance of the query.  If multiple query plans are possible, MongoDB will run all of them in parallel for a short while, will determine which one is the best-performing query, and will use that plan for the remainder of the query.  Once a query plan is in place, it is cached for reuse.  Query plans are re-evaluated on a regular basis.&lt;/li&gt;
	&lt;li&gt;MongoDB can only use a single index for a query.  If you have individual indexes on fields A, B, and C within a document, and you perform a query using all three fields as part of the condition, then MongoDB will pick only one index for the query, and will scan the documents returned by the most performant index to meet the conditions on the other two fields&lt;/li&gt;
	&lt;li&gt;MongoDB supports compound indexes.  Compound indexes allow you to perform indexed queries that use indexes on multiple fields.  For example, if you have an index on 
{a:1,b:1}
&lt;p&gt;, then you can do a query of the form &lt;/p&gt;
{a:&quot;value&quot;, b:&quot;othervalue&quot;}
&lt;p&gt; and the query will be run entirely using the index: there&apos;s no need to scan any documents to find the precise result set&lt;/p&gt;&lt;/li&gt;
	&lt;li&gt;A regular expression can only make maximum use of an index if it is a simple prefix query&lt;/li&gt;
	&lt;li&gt;However, a more complex regular expression can make partial use of the index, if the regex refers to an indexed field.  For example, given the index above, a query of the form 
{a:&quot;value&quot;, b: /other*lue/ }
&lt;p&gt; would be able to fully use the index to match all documents where field &apos;a&apos; has the value &apos;value&apos;.  The query engine would then have to run the regular expression engine across all of the values of &apos;b&apos; in that preliminary set.  If &apos;b&apos; is indexed, then the query engine can use the value stored in the index, without having to fetch the actual document.&lt;/p&gt;&lt;/li&gt;
	&lt;li&gt;On the other hand, if the regex refers to an unindexed field (or one not included in the chosen index) then the query engine must fetch the entire document off of disk in order to execute the query.  For example, assuming the index above, a query of the form 
{a:&quot;value&quot;, c:/other*/ }
&lt;p&gt; would require that all documents that match &lt;/p&gt;
{a:&quot;value&quot;}
&lt;p&gt; be fetched from disk so that the query engine can filter them.  In the general case, this will be considerably slower than only examining the index.&lt;/p&gt;&lt;/li&gt;
	&lt;li&gt;In addition to the above, if the regex is being used to query a field which contains an array, it will always fetch the entire document from disk: regex queries of array fields are never performed only using the index.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The point of all this is the following: multiple regex expressions in a single query may or may not impact performance.&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;If you add an additional regex condition on a field that is already being used for a regex query, then performance will be essentially unaffected&lt;/li&gt;
	&lt;li&gt;If you have an existing regex condition on a field that is present in the index being used, and you add an additional regex condition on a field that is also present in the index being used, then performance will also be unaffected&lt;/li&gt;
	&lt;li&gt;If you have an existing regex condition on a field that is NOT present in the index being used, then adding additional regex conditions on other unindexed fields will not affect performance&lt;/li&gt;
	&lt;li&gt;If you have an existing regex condition on a field that is NOT present in the index being used, then adding additional regex conditions on fields which ARE included in the index will actually improve performance&lt;/li&gt;
	&lt;li&gt;If you have an existing regex condition on a field that is present in the index being used, and you add an additional regex condition on a field that is not present in the index, then performance will be decreased.&lt;/li&gt;
&lt;/ul&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10855" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Actual Time</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 22 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>jess.mokrzecki@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 22 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>kay.kim@mongodb.com</customfieldvalue>
            <customfieldvalue>william.zola@10gen.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrsbhr:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>16848</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_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hry5cf:</customfieldvalue>

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