<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:58:57 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-2094] distinct cheat with indexes</title>
                <link>https://jira.mongodb.org/browse/SERVER-2094</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Right now distinct will pull data out of indexes, but will scan the entire thing.&lt;br/&gt;
Can skip whole regions where the key is the same&lt;/p&gt;

&lt;p&gt;Correct way to implement is probably adding a method to a btree bucket like&lt;/p&gt;

&lt;p&gt;getDisinctKeys( int keyOffset )&lt;/p&gt;</description>
                <environment></environment>
        <key id="13691">SERVER-2094</key>
            <summary>distinct cheat with indexes</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="9">Done</resolution>
                                        <assignee username="hari.khalsa@10gen.com">hari.khalsa@10gen.com</assignee>
                                    <reporter username="eliot">Eliot Horowitz</reporter>
                        <labels>
                    </labels>
                <created>Sun, 14 Nov 2010 06:53:46 +0000</created>
                <updated>Fri, 7 Apr 2023 16:40:23 +0000</updated>
                            <resolved>Thu, 23 Jan 2014 19:20:08 +0000</resolved>
                                                    <fixVersion>2.5.5</fixVersion>
                                    <component>Performance</component>
                                        <votes>31</votes>
                                    <watches>39</watches>
                                                                                                                <comments>
                            <comment id="519173" author="xgen-internal-githook" created="Wed, 19 Mar 2014 14:48:49 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;hkhalsa&apos;, u&apos;name&apos;: u&apos;Hari Khalsa&apos;, u&apos;email&apos;: u&apos;hkhalsa@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-10026&quot; title=&quot;New query system&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-10026&quot;&gt;&lt;del&gt;SERVER-10026&lt;/del&gt;&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-13271&quot; title=&quot;remove surplus projection from distinct&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-13271&quot;&gt;&lt;del&gt;SERVER-13271&lt;/del&gt;&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-12878&quot; title=&quot;Aggregations that do not return cursors need to clean up internal cursors&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-12878&quot;&gt;&lt;del&gt;SERVER-12878&lt;/del&gt;&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2094&quot; title=&quot;distinct cheat with indexes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2094&quot;&gt;&lt;del&gt;SERVER-2094&lt;/del&gt;&lt;/a&gt; avoid surplus projections in distinct&lt;br/&gt;
Branch: v2.6&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/094f1565d6f82859bc38300b45564dd1ea9f070e&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/094f1565d6f82859bc38300b45564dd1ea9f070e&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="519169" author="xgen-internal-githook" created="Wed, 19 Mar 2014 14:48:05 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;hkhalsa&apos;, u&apos;name&apos;: u&apos;Hari Khalsa&apos;, u&apos;email&apos;: u&apos;hkhalsa@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-10026&quot; title=&quot;New query system&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-10026&quot;&gt;&lt;del&gt;SERVER-10026&lt;/del&gt;&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-13271&quot; title=&quot;remove surplus projection from distinct&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-13271&quot;&gt;&lt;del&gt;SERVER-13271&lt;/del&gt;&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-12878&quot; title=&quot;Aggregations that do not return cursors need to clean up internal cursors&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-12878&quot;&gt;&lt;del&gt;SERVER-12878&lt;/del&gt;&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2094&quot; title=&quot;distinct cheat with indexes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2094&quot;&gt;&lt;del&gt;SERVER-2094&lt;/del&gt;&lt;/a&gt; avoid surplus projections in distinct&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/267f56a7e0ce36eba21b4b2ef09e32a43370acbf&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/267f56a7e0ce36eba21b4b2ef09e32a43370acbf&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="487157" author="eliot" created="Fri, 24 Jan 2014 11:57:32 +0000"  >&lt;p&gt;Sebastian, no, a backport isn&apos;t possible.  This relies on the query execution system going in 2.6.&lt;/p&gt;</comment>
                            <comment id="487116" author="sebastian.paul@maloon.de" created="Fri, 24 Jan 2014 09:22:57 +0000"  >&lt;p&gt;is it possible that this can be backported to 2.4 stable?&lt;/p&gt;</comment>
                            <comment id="486692" author="xgen-internal-githook" created="Thu, 23 Jan 2014 19:19:53 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;hkhalsa&apos;, u&apos;name&apos;: u&apos;Hari Khalsa&apos;, u&apos;email&apos;: u&apos;hkhalsa@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2094&quot; title=&quot;distinct cheat with indexes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2094&quot;&gt;&lt;del&gt;SERVER-2094&lt;/del&gt;&lt;/a&gt; fast distinct when field is indexed and query is fully covered&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/05db1ea493f0bb00215e0dd94988f9aa927925bc&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/05db1ea493f0bb00215e0dd94988f9aa927925bc&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="483991" author="xgen-internal-githook" created="Fri, 17 Jan 2014 23:30:05 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;hkhalsa&apos;, u&apos;name&apos;: u&apos;Hari Khalsa&apos;, u&apos;email&apos;: u&apos;hkhalsa@10gen.com&apos;}
&lt;p&gt;Message: Revert &quot;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2094&quot; title=&quot;distinct cheat with indexes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2094&quot;&gt;&lt;del&gt;SERVER-2094&lt;/del&gt;&lt;/a&gt; distinct only wants the field it&apos;s distinct-ing over&quot;&lt;/p&gt;

&lt;p&gt;This reverts commit 3b5b31f42d390e9da23f66e78a300d997ae653c4.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/5f169de0c5a1651efe39eaa6165c4a3414470dd7&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/5f169de0c5a1651efe39eaa6165c4a3414470dd7&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="483878" author="xgen-internal-githook" created="Fri, 17 Jan 2014 20:15:28 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;hkhalsa&apos;, u&apos;name&apos;: u&apos;Hari Khalsa&apos;, u&apos;email&apos;: u&apos;hkhalsa@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-2094&quot; title=&quot;distinct cheat with indexes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-2094&quot;&gt;&lt;del&gt;SERVER-2094&lt;/del&gt;&lt;/a&gt; distinct only wants the field it&apos;s distinct-ing over&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/3b5b31f42d390e9da23f66e78a300d997ae653c4&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/3b5b31f42d390e9da23f66e78a300d997ae653c4&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="468265" author="richard@teleport.com.au" created="Tue, 10 Dec 2013 00:06:29 +0000"  >&lt;p&gt;@Benjamin - Your optimization is awesome ! Thanks x 1000 (the performance improvement I got). &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                            <comment id="466146" author="sebastian.paul@maloon.de" created="Thu, 5 Dec 2013 14:47:51 +0000"  >&lt;p&gt;same here. Using distinct to get log levels.&lt;br/&gt;
nothing more than&lt;br/&gt;
db.logging.distinct(&apos;level&apos;);&lt;/p&gt;

&lt;p&gt;Index is set&lt;/p&gt;

&lt;p&gt;13 million objects in a capped collection&lt;br/&gt;
takes about 8 s&lt;/p&gt;</comment>
                            <comment id="435069" author="aszpakowski" created="Thu, 3 Oct 2013 09:45:40 +0000"  >&lt;p&gt;Same problem here, distinct takes ~4s (seconds) on indexed collection. Collection fits in RAM, index is used &quot;nscannedObjects&quot; : 0.&lt;/p&gt;

&lt;p&gt;&amp;gt; db.runCommand(&lt;/p&gt;
{distinct: &quot;sab.sessions&quot;, key: &quot;customer&quot;}
&lt;p&gt;)&lt;br/&gt;
{&lt;br/&gt;
        &quot;values&quot; : [...              &amp;lt;-- 5 distinct values&lt;br/&gt;
        ],&lt;br/&gt;
        &quot;stats&quot; : &lt;/p&gt;
{
                &quot;n&quot; : 7274033,
                &quot;nscanned&quot; : 7274033,
                &quot;nscannedObjects&quot; : 0,
                &quot;timems&quot; : 4043,
                &quot;cursor&quot; : &quot;BtreeCursor customer_1&quot;
        }
&lt;p&gt;,&lt;br/&gt;
        &quot;ok&quot; : 1&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;Now withouth index, it takes ~6.5 seconds:&lt;br/&gt;
&amp;gt; db.runCommand(&lt;/p&gt;
{distinct: &quot;sab.sessions&quot;, key: &quot;customer&quot;}
&lt;p&gt;)&lt;br/&gt;
{&lt;br/&gt;
        &quot;values&quot; : &lt;span class=&quot;error&quot;&gt;&amp;#91;...&amp;#93;&lt;/span&gt;,&lt;br/&gt;
        &quot;stats&quot; : &lt;/p&gt;
{
                &quot;n&quot; : 7274033,
                &quot;nscanned&quot; : 7274033,
                &quot;nscannedObjects&quot; : 7274033,
                &quot;timems&quot; : 6553,
                &quot;cursor&quot; : &quot;BasicCursor&quot;
        }
&lt;p&gt;,&lt;br/&gt;
        &quot;ok&quot; : 1&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;I&apos;ve tried both normal and hashed inices.&lt;/p&gt;</comment>
                            <comment id="348580" author="eliot" created="Thu, 30 May 2013 05:20:05 +0000"  >&lt;p&gt;Ali - nscannedObjects is 0, which implied that is in fact using the index.&lt;br/&gt;
Basically its taking ~8ms to walk the entire index.&lt;/p&gt;</comment>
                            <comment id="346276" author="aliwatters" created="Mon, 27 May 2013 15:17:41 +0000"  >&lt;p&gt;On 2.4.3 &amp;#8211; collection with an index on a field with ~100 distinct values, and ~4.5 million docs.&lt;/p&gt;

&lt;p&gt;~8s on ok server (working set in memory) to run &amp;gt; db.action_log.distinct(&apos;action&apos;);&lt;/p&gt;

&lt;p&gt;Distinct does not use the index action_1, appears to be running a table scan.&lt;/p&gt;

&lt;p&gt;&amp;gt; db.runCommand(&lt;/p&gt;
{ distinct: &apos;action_log&apos;, key:&apos;action&apos;}
&lt;p&gt;);&lt;br/&gt;
{ &quot;values&quot;: [ ...&lt;br/&gt;
	],&lt;br/&gt;
	&quot;stats&quot; : &lt;/p&gt;
{
		&quot;n&quot; : 4497162,
		&quot;nscanned&quot; : 4497162,
		&quot;nscannedObjects&quot; : 0,
		&quot;timems&quot; : 7900,
		&quot;cursor&quot; : &quot;BtreeCursor action_1&quot;
	}
&lt;p&gt;,&lt;br/&gt;
	&quot;ok&quot; : 1&lt;br/&gt;
}&lt;/p&gt;

&lt;p&gt;Something feels broken as &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1673&quot; title=&quot;Allow distinct to use indexes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1673&quot;&gt;&lt;del&gt;SERVER-1673&lt;/del&gt;&lt;/a&gt; is marked as fixed.&lt;/p&gt;</comment>
                            <comment id="207331" author="hltbra" created="Wed, 5 Dec 2012 19:20:56 +0000"  >&lt;p&gt;@Benjamin, thank you very much for this hack! I hope mongodb team write a better distinct asap.&lt;/p&gt;</comment>
                            <comment id="202915" author="benjaminjackman" created="Fri, 30 Nov 2012 06:32:33 +0000"  >&lt;p&gt;For those stuck with this problem I used a work around &lt;br/&gt;
that gave me a several orders of magnitude faster results.&lt;/p&gt;

&lt;p&gt;My use case did not have a compound key, but perhaps this can be adapted for&lt;br/&gt;
those use cases.&lt;/p&gt;

&lt;p&gt;The idea is to first find the smallest key via sort,&lt;br/&gt;
then use that in a find() to get the next distinct key &lt;br/&gt;
via combination of $gt the last key and sort()&lt;br/&gt;
repeating until all are found.&lt;/p&gt;

&lt;p&gt;Here a js version that could be entered at the command substituting in &lt;br/&gt;
%COL% with your collection name, and&lt;br/&gt;
%KEY% with the key you are trying to select distinct, ensure it is indexed&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;   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;function() {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;  //create a find that returns the lowest value set for %KEY% in %COL%&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;  var f = function (q) {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;    var cur = db[%COL%].find(q, {&quot;%KEY%&quot;:1}).sort({&quot;%KEY%&quot;:1})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;    if (cur.hasNext()) {return cur.next().%KEY%} else {return null}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;  }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;  var cur = f({})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;  var ret = [];&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;  while (cur != null) {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;    ret.push(cur);&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;    cur = f({&quot;%KEY%&quot;:{&quot;$gt&quot;:cur}})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;  }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;  return ret;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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-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;}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;


</comment>
                            <comment id="156059" author="turneliusz" created="Thu, 23 Aug 2012 13:41:53 +0000"  >&lt;p&gt;Same problem like @Sergey Alaev:&lt;br/&gt;
1. find region by city&lt;br/&gt;
2. find cities by region and country&lt;br/&gt;
3. find streets by country, region and city.&lt;/p&gt;

&lt;p&gt;+1 for the future anyway&lt;/p&gt;</comment>
                            <comment id="156057" author="jason.coombs@yougov.com" created="Thu, 23 Aug 2012 13:36:09 +0000"  >&lt;p&gt;Our use case is simple - we have a chat log server where all log entries are stored in a single collection, one field which is the &apos;channel&apos;, indexed.&lt;/p&gt;

&lt;p&gt;We would like to determine quickly which channels have been logged. It&apos;s a small number of items (&amp;lt;50) compared to the number of log entries (&amp;gt;1M). We would like to retrieve the channels without scanning every log entry (or index entry).&lt;/p&gt;</comment>
                            <comment id="68056" author="kevin1024" created="Mon, 21 Nov 2011 21:08:03 +0000"  >&lt;p&gt;One more use case to add to the pile:&lt;/p&gt;

&lt;p&gt;We have a few million real estate properties with things like city, state, neighborhood, condo building name, etc.&lt;/p&gt;

&lt;p&gt;We do lots of distincts.  For example:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;List of all distinct neighborhoods in San Diego&lt;/li&gt;
	&lt;li&gt;List of all distinct neighborhoods in a certain region of San Diego&lt;/li&gt;
	&lt;li&gt;List of all distinct building names in a list of neighborhoods in San Diego&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;We cache these but the data changes constantly so that only goes so far.  We can&apos;t really denormalize / precompute these because there are so many combinations of the filter criteria that it isn&apos;t practical.&lt;/p&gt;</comment>
                            <comment id="67836" author="wouteralleweireldt" created="Mon, 21 Nov 2011 09:44:30 +0000"  >&lt;p&gt;@Eliot:&lt;/p&gt;

&lt;p&gt;we&apos;re keeping track on a set of our data with of a sort of timestamp field (year field/month field/day field), and we need a distinct on each of those fields to return only the dates that have valid data. Right now we need to run 3 queries : distinct on year, dinstinct on month for that year, distinct on day for that month/year, and totals up to (sometimes over) a second on a rather small set of data (1.1 million docs) which is way to slow for our needs (compared to SQL running the very same query, taking only a few millisecs)&lt;/p&gt;</comment>
                            <comment id="67591" author="scf37" created="Fri, 18 Nov 2011 13:50:18 +0000"  >&lt;p&gt;I am waiting for this ticked too - it is very important for fast queries on denormalized trees&lt;br/&gt;
Our case is address database which is basically a tree: country-region-city-street-house&lt;br/&gt;
Queries we need:&lt;br/&gt;
1. find region by city&lt;br/&gt;
2. find cities by region and country&lt;br/&gt;
3. find streets by country, region and city.&lt;/p&gt;

&lt;p&gt;The only way i found is denormalized tree, but in this case query 2 returns HUGE amount of duplicate cities.&lt;/p&gt;

&lt;p&gt;And currently MongoDB&apos;s distinct is not much faster than implemented in java on client side.&lt;/p&gt;

&lt;p&gt;edit: denormalization is the only way to avoid client-side joins, but if you do not want to build different collections for different join combinations, effective grouping or distinct is required. Something like that &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                            <comment id="67588" author="eliot" created="Fri, 18 Nov 2011 13:31:58 +0000"  >&lt;p&gt;@wouter - what&apos;s the example you have?  just to see if its really relevant&lt;/p&gt;</comment>
                            <comment id="67580" author="wouteralleweireldt" created="Fri, 18 Nov 2011 12:22:45 +0000"  >&lt;p&gt;Any idea when this could be implemented?&lt;br/&gt;
Some of our queries require a fast distinct, but the way distinct is working now, we&apos;re not getting the performance we need...&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="12901">SERVER-1673</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="100949">SERVER-11939</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="384237">SERVER-29244</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="105240">SERVER-12297</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="73561">SERVER-9507</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="122611">SERVER-13271</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>21.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 18 Nov 2011 12:22:45 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        9 years, 48 weeks ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[<s><a href='https://jira.mongodb.org/browse/SERVER-1673'>SERVER-1673</a></s>, <s><a href='https://jira.mongodb.org/browse/SERVER-11939'>SERVER-11939</a></s>]]></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>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            9 years, 48 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>aszpakowski</customfieldvalue>
            <customfieldvalue>aliwatters</customfieldvalue>
            <customfieldvalue>benjaminjackman</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>hari.khalsa@10gen.com</customfieldvalue>
            <customfieldvalue>hltbra</customfieldvalue>
            <customfieldvalue>jason.coombs@yougov.com</customfieldvalue>
            <customfieldvalue>kevin1024</customfieldvalue>
            <customfieldvalue>richard@teleport.com.au</customfieldvalue>
            <customfieldvalue>sebastian.paul@maloon.de</customfieldvalue>
            <customfieldvalue>scf37</customfieldvalue>
            <customfieldvalue>turneliusz</customfieldvalue>
            <customfieldvalue>wouteralleweireldt</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrpbf3:</customfieldvalue>

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

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

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

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