title: How to efficiently perform "distinct" with multiple keys?
body: <p>For example, there is a collection like this:<br/></p>
  
  <blockquote>
    <p>{market: 'SH', code: '000001', date: '2012-01-01', price: 1000}<br/>
    {market: 'SZ', code: '000001', date: '2012-01-01', price: 1000}<br/>
    {market: 'SH', code: '000001', date: '2012-01-02', price: 1000}<br/>
    {market: 'SZ', code: '000001', date: '2012-01-02', price: 1000}<br/>
    {market: 'SH', code: '000002', date: '2012-01-03',price: 1000}<br/>
    ...</p>
  </blockquote>
  
  <p>This collection contains tens of millions documents.</p>
  
  <p>I want to call distinct with two keys:<br/></p>
  
  <pre><code>collection.distinct('market', 'code');
  </code></pre>
  
  <p>and get result :</p>
  
  <blockquote>
    <p>[{market: 'SH', code:'000001'},
    {market: 'SZ', code:'000001'},
    {market: 'SH', code:'000002'}]</p>
  </blockquote>
  
  <p>As native distinct command accept only one key, I try to implement it by using map-reduce. But map-reduce is far too slow to native distinct. In my one-key distinct test, map-reduce spend about ten times longer than native distinct.<br/>
  Is there a efficient way to implement multikey distinct?</p>