<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:07:04 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-4815] Creating a unique index should have an ignore null values option</title>
                <link>https://jira.mongodb.org/browse/SERVER-4815</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I&apos;ve seen Issue 2028 (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2028&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/SERVER-2028&lt;/a&gt;) and I don&apos;t think a sparse index is a good enough solution. One of the reasons I think a sparse index fails as a solution is because when the index is used in a lookup, the documents that &lt;b&gt;do&lt;/b&gt; have null values in the indexed field are ignored in search results. Let me give a concrete example of what I think the behavior should be...&lt;/p&gt;

&lt;p&gt;Let&apos;s say I&apos;m adding a new property to a &quot;users&quot; collection. The new property is an api token, and needs to be unique across the entire collection. I&apos;d like to be able to do db.users.ensureIndex(&lt;/p&gt;
{&quot;token&quot;: 1, &quot;unique&quot;: true}
&lt;p&gt;), but this will of course fail b/c mongo will hit more than one null value. On the other hand, a sparse index here doesn&apos;t work because when I try to do a read query on that column where that column would get used (db.users.find({token: {&quot;$ne&quot;: null}}).count) the result set excludes all the users b/c it&apos;s a new property.&lt;/p&gt;</description>
                <environment></environment>
        <key id="29458">SERVER-4815</key>
            <summary>Creating a unique index should have an ignore null values option</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="backlog-query-optimization">Backlog - Query Optimization</assignee>
                                    <reporter username="ajsharp">Alex Sharp</reporter>
                        <labels>
                            <label>indexv3</label>
                    </labels>
                <created>Mon, 30 Jan 2012 21:40:50 +0000</created>
                <updated>Tue, 12 Sep 2023 20:41:16 +0000</updated>
                                            <version>2.0.2</version>
                                                    <component>Index Maintenance</component>
                                        <votes>6</votes>
                                    <watches>9</watches>
                                                                                                                <comments>
                            <comment id="4526702" author="asya" created="Wed, 4 May 2022 19:15:05 +0000"  >&lt;p&gt;&amp;gt; I&apos;d like to see an option to prevent null values altogether on unique indexes&lt;/p&gt;

&lt;p&gt;While not specific to unique indexes, &lt;a href=&quot;https://www.mongodb.com/docs/manual/core/schema-validation/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;document validation&lt;/a&gt; allows creating rules which won&apos;t allow explicitly null fields (while allowing the field to not be set if that&apos;s appropriate).&lt;/p&gt;</comment>
                            <comment id="274156" author="daniel.sinclair@nupe.com" created="Sat, 23 Feb 2013 21:46:36 +0000"  >&lt;p&gt;I think unique sparse indexes already work the way they should. I&apos;m happy with the differentiation between missing and null fields and I think it&apos;s an important distinction.&lt;/p&gt;

&lt;p&gt;However, I&apos;d like to see an option to prevent null values altogether on unique indexes. It doesn&apos;t make sense to me. Particularly, as the first time you add an entry with a null field it works just fine. I&apos;m picking this up in my unit tests (just about). I&apos;d prefer that if anyone tried to add a document with a null field that&apos;s required for the unique index it should reject even the very FIRST entry as an index violation. If I want to use the sparse index, I&apos;ll make my fields sparse.&lt;/p&gt;

&lt;p&gt;This would trap errors better IMHO.&lt;/p&gt;</comment>
                            <comment id="122089" author="ajsharp" created="Tue, 22 May 2012 21:52:00 +0000"  >&lt;p&gt;It appears that the sparse option will only work if the documents don&apos;t have values set at all for the unique sparse field. If there is a value set, and it is null, document insert will fail due to a uniqueness violation. For unique indexes, null values should behave the same as an unset field.&lt;/p&gt;</comment>
                            <comment id="122055" author="ajsharp" created="Tue, 22 May 2012 20:36:41 +0000"  >&lt;p&gt;Have there been any updates on this?&lt;/p&gt;</comment>
                            <comment id="88943" author="eliot" created="Thu, 16 Feb 2012 06:25:18 +0000"  >&lt;p&gt;This probably should be the default like postgres, et al.&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>5.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>Thu, 16 Feb 2012 06:25:18 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 40 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>christopher.harris@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            1 year, 40 weeks 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>ajsharp</customfieldvalue>
            <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>backlog-query-optimization</customfieldvalue>
            <customfieldvalue>daniel.sinclair@nupe.com</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrof87:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4143</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|ht0q7b:</customfieldvalue>

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