<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:04:56 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-66267] Exploit RID = _id for secondary index on clustered collections?</title>
                <link>https://jira.mongodb.org/browse/SERVER-66267</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;If I understand correctly, on a clustered collection the _id field is the same as the record ID (RID).  Does this mean that any secondary index also includes the _id value?  For example, an index on {a: 1} is really a set of (a, _id) entries, almost like an index on {a: 1, _id: 1}.&lt;/p&gt;

&lt;p&gt;Could we use an {a: 1} index to satisfy queries like {$sort: {a: 1, _id: 1}}?&lt;/p&gt;</description>
                <environment></environment>
        <key id="2040793">SERVER-66267</key>
            <summary>Exploit RID = _id for secondary index on clustered collections?</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="1" iconUrl="https://jira.mongodb.org/images/icons/statuses/open.png" description="">Open</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.percy@mongodb.com">David Percy</reporter>
                        <labels>
                    </labels>
                <created>Thu, 5 May 2022 21:21:29 +0000</created>
                <updated>Tue, 6 Dec 2022 00:08:27 +0000</updated>
                                                                                                <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4537844" author="louis.williams" created="Tue, 10 May 2022 12:40:43 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=david.percy%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;david.percy@mongodb.com&quot;&gt;david.percy@mongodb.com&lt;/a&gt;, if just for sorting, that that&apos;s okay. We require the _id to be an ObjectId for time-series collections using a &lt;a href=&quot;https://github.com/mongodb/mongo/blob/c6e976d9f67a1b50826784e7a0eda9bfe212dd73/src/mongo/db/catalog/create_collection.cpp#L254&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;document validator&lt;/a&gt;, so yes, I think that would work.&lt;/p&gt;</comment>
                            <comment id="4532415" author="david.percy" created="Fri, 6 May 2022 19:51:10 +0000"  >&lt;p&gt;Interesting, thanks for the explanation!&lt;/p&gt;

&lt;p&gt;If we&apos;re only interested in sorting, not covered projections, I think it&apos;s ok that the type bits aren&apos;t included.  Things like NumberLong(5) vs 5.0, which have the same value but different type bits, are supposed to compare equal when we sort them.  So if an index on {a: 1} gives us documents ordered by (keystring(a), keystring(_id)), I think that&apos;s a correct order to satisfy {$sort: {a: 1, _id: 1}}.&lt;/p&gt;

&lt;p&gt;If we did want to do covered projections, just for timeseries collections, maybe we could assume that the _id field is always an ObjectId?&lt;/p&gt;</comment>
                            <comment id="4530554" author="louis.williams" created="Fri, 6 May 2022 08:18:40 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=david.percy%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;david.percy@mongodb.com&quot;&gt;david.percy@mongodb.com&lt;/a&gt;, the issue is that we discard the TypeBits when KeyString-ifying the _id value to generate a RecordId. &lt;a href=&quot;https://github.com/mongodb/mongo/blob/0dbec1c169b701f2c6547ef3b40e477f0a49bc00/src/mongo/db/record_id_helpers.cpp#L115&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;See here&lt;/a&gt;. We don&apos;t take the TypeBits from the KeyString::Builder and we don&apos;t store them anywhere. The reason this is safe is that the original type information is stored in the BSON object, which we would have already paged into cache by seeking on the clustered collection.&lt;/p&gt;

&lt;p&gt;The consequence is that a covered index scan would not be able to know the original type of the _id. For example: If the _id was NumberLong(42), the RecordId (as a KeyString) would  encode that as a small integer. When we query, we would need the TypeBits to tell us that the original value was NumberLong, not an int.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.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_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 6 May 2022 08:18:40 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 39 weeks, 1 day 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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-2793</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.golin@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            1 year, 39 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>backlog-query-optimization</customfieldvalue>
            <customfieldvalue>david.percy@mongodb.com</customfieldvalue>
            <customfieldvalue>louis.williams@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i0tvjz:</customfieldvalue>

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

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