<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:58:10 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-41594] Covered query don&apos;t use index for range $gt+$lt. Only for one side and FETCH filter for another</title>
                <link>https://jira.mongodb.org/browse/SERVER-41594</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;There is field&#160;&lt;b&gt;contracts&lt;/b&gt;, that contain &lt;b&gt;array of objects,&lt;/b&gt;&#160;that objects have indexed string field &lt;b&gt;dateSigned&lt;/b&gt;&#160;(example value &quot;2016-09-23T18:02:00+02:02&quot;). Query with&#160;&lt;b&gt;count&lt;/b&gt;&#160;and &lt;b&gt;$lt&lt;/b&gt; (same for &lt;b&gt;$gt&lt;/b&gt;) use index&#160;and all works great, stage&#160;&lt;b&gt;COUNT_SCAN&lt;/b&gt;. But query with &lt;b&gt;both $gt&#160;and $lt&lt;/b&gt; use index only for one bound and&#160;&lt;b&gt;FETCH&lt;/b&gt;&#160;for another, that cause very poor perfomence.&lt;/p&gt;

&lt;p&gt;Why index can&apos;t use both bounds?&lt;/p&gt;

&lt;p&gt;Also I try to convert string value of &lt;b&gt;dateSigned&lt;/b&gt;&#160;to ISODate, add new field &lt;b&gt;dateSignedDate&lt;/b&gt;. Create index on that field - works same way.&lt;/p&gt;</description>
                <environment></environment>
        <key id="794666">SERVER-41594</key>
            <summary>Covered query don&apos;t use index for range $gt+$lt. Only for one side and FETCH filter for another</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="eric.sedor@mongodb.com">Eric Sedor</assignee>
                                    <reporter username="devbocharov">Bocharov Vladislav</reporter>
                        <labels>
                    </labels>
                <created>Mon, 10 Jun 2019 10:20:58 +0000</created>
                <updated>Wed, 12 Jun 2019 19:07:08 +0000</updated>
                            <resolved>Wed, 12 Jun 2019 19:07:08 +0000</resolved>
                                    <version>4.0.9</version>
                    <version>4.0.10</version>
                                                    <component>Index Maintenance</component>
                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="2281705" author="eric.sedor" created="Wed, 12 Jun 2019 19:05:10 +0000"  >&lt;p&gt;Thanks &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=devbocharov&quot; class=&quot;user-hover&quot; rel=&quot;devbocharov&quot;&gt;devbocharov&lt;/a&gt;. We are going to close this ticket as a duplicate of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-23118&quot; title=&quot;Update index bounds generation rules for index intersection in the PlanEnumerator given path-level multikey info&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-23118&quot;&gt;SERVER-23118&lt;/a&gt;, which is an effort to improve the generation of index bounds (independent of implementation details). You can watch that ticket for updates.&lt;/p&gt;</comment>
                            <comment id="2280894" author="devbocharov" created="Wed, 12 Jun 2019 11:59:19 +0000"  >&lt;p&gt;UPD: I understand that my approach will also give wrong result sometimes if array has more then one elements, so it probably can be done (at least I have no suggestions how do this).&lt;br/&gt;
 So you can close this issue.&lt;/p&gt;

&lt;p&gt;UPD2: One developer came up with such idea: add number of element of the array before recordId to index. So for two index scans we will get two sets like {(5, recId12), (0, recId434), ...} and intersect of it will give correct results.&lt;br/&gt;
What about such index upgrade or array of fields? Maybe it already in work?&lt;/p&gt;</comment>
                            <comment id="2280879" author="devbocharov" created="Wed, 12 Jun 2019 11:47:33 +0000"  >&lt;p&gt;Thanks for replay, I read your sources. So problem is that: when we do only one side search, we get correct result, but when we add another bound we get another results, that maybe don&apos;t match first filter. But what about such scenario:&lt;br/&gt;
1) we use index with first predicate and get set of docs references (or _id, don&apos;t know how its work in fact), let call it A;&lt;br/&gt;
2) then we use index for second predicate, get set B;&lt;br/&gt;
3) simple intersect them - A&amp;amp;B, add count or FETCH result, whatever we need.&lt;/p&gt;

&lt;p&gt;So instead of intersect index ranges, we intersect its subsets results for each predicate. In my case it is $lt and $gt, but generally it could be any filter on array field.&lt;br/&gt;
It&apos;s simple idea, but I can&apos;t see why it wont work.&lt;/p&gt;</comment>
                            <comment id="2280277" author="eric.sedor" created="Tue, 11 Jun 2019 20:42:46 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=devbocharov&quot; class=&quot;user-hover&quot; rel=&quot;devbocharov&quot;&gt;devbocharov&lt;/a&gt;; this behavior is expected for multikey indexes and is documented &lt;a href=&quot;https://docs.mongodb.com/manual/core/index-multikey/#covered-queries&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can read more details about this in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-35223&quot; title=&quot;$elemMatch forces mongo to fetch documents instead of using COUNT_SCAN&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-35223&quot;&gt;&lt;del&gt;SERVER-35223&lt;/del&gt;&lt;/a&gt; and &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-6720&quot; title=&quot;Range query with compound multikey index scans more objects than needed&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-6720&quot;&gt;&lt;del&gt;SERVER-6720&lt;/del&gt;&lt;/a&gt;, but in short: Counting on a single criteria without $elemMatch is an exception that can be handled with a COUNT_SCAN, but other combinations cannot.&lt;/p&gt;

&lt;p&gt;Does this make sense?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="272244">SERVER-23118</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="794275">SERVER-41590</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="46322">SERVER-6720</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="549661">SERVER-35223</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="272244">SERVER-23118</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="219941" name="signedTest.json" size="8135226" author="devbocharov" created="Mon, 10 Jun 2019 10:20:55 +0000"/>
                    </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_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 11 Jun 2019 20:42:46 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        4 years, 35 weeks 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>eric.sedor@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            4 years, 35 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>devbocharov</customfieldvalue>
            <customfieldvalue>eric.sedor@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hv3v8n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hut24v:</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_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </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>
                                    <customfieldvalue><![CDATA[eric.sedor@mongodb.com]]></customfieldvalue>
    

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hv3hhz:</customfieldvalue>

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