<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:35: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>[CSHARP-144] MongoCollection Can&apos;t distinct a large size of data</title>
                <link>https://jira.mongodb.org/browse/CSHARP-144</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I have a collection contains about 821463 documents in my local mongodb.I try to distinct TrackID in C# Program with the method Distinct(string key) of MongoCollection.I got a Exception,Message is:&lt;br/&gt;
Invalid BSONObj spec size: 25354392 (98E08201)&lt;br/&gt;
The stack trace is below:&lt;br/&gt;
   At MongoDB.Driver.Internal.MongoReplyMessage`1.ReadFrom(BsonBuffer buffer)&lt;br/&gt;
   At MongoDB.Driver.Internal.MongoConnection.ReceiveMessage&lt;span class=&quot;error&quot;&gt;&amp;#91;TDocument&amp;#93;&lt;/span&gt;()&lt;br/&gt;
   At MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.GetReply(MongoRequestMessage message)&lt;br/&gt;
   At MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.GetFirst()&lt;br/&gt;
   At MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.MoveNext()&lt;br/&gt;
   At System.Linq.Enumerable.FirstOrDefault&lt;span class=&quot;error&quot;&gt;&amp;#91;TSource&amp;#93;&lt;/span&gt;(IEnumerable`1 source)&lt;br/&gt;
   At MongoDB.Driver.MongoCollection.FindOneAs&lt;span class=&quot;error&quot;&gt;&amp;#91;TQuery,TDocument&amp;#93;&lt;/span&gt;(TQuery query)&lt;br/&gt;
   At MongoDB.Driver.MongoCollection`1.FindOne&lt;span class=&quot;error&quot;&gt;&amp;#91;TQuery&amp;#93;&lt;/span&gt;(TQuery query)&lt;br/&gt;
   At MongoDB.Driver.MongoDatabase.RunCommand&lt;span class=&quot;error&quot;&gt;&amp;#91;TCommand&amp;#93;&lt;/span&gt;(TCommand command)&lt;br/&gt;
   At MongoDB.Driver.MongoCollection.Distinct&lt;span class=&quot;error&quot;&gt;&amp;#91;TQuery&amp;#93;&lt;/span&gt;(String key, TQuery query)&lt;br/&gt;
   At MongoDB.Driver.MongoCollection.Distinct(String key)&lt;br/&gt;
   At MongoWriteSpeed.Program.Main(String[] args) Location E:\Program\WindowsProject\MongoWriteSpeed\MongoWriteSpeed\Program.cs:row 27&lt;/p&gt;

&lt;p&gt;My Program is Below:&lt;/p&gt;

&lt;p&gt;using System;&lt;br/&gt;
using System.Collections.Generic;&lt;br/&gt;
using System.Linq;&lt;br/&gt;
using System.Text;&lt;/p&gt;

&lt;p&gt;using MongoDB.Driver;&lt;br/&gt;
using MongoDB.Bson;&lt;/p&gt;

&lt;p&gt;namespace MongoWriteSpeed&lt;br/&gt;
{&lt;br/&gt;
    class Program&lt;br/&gt;
    {&lt;br/&gt;
        static void Main(string[] args)&lt;br/&gt;
        {&lt;br/&gt;
            MongoServer _dbServer = MongoServer.Create();&lt;/p&gt;

&lt;p&gt;            try&lt;br/&gt;
            {&lt;br/&gt;
                if ((_dbServer.State == MongoServerState.Disconnected) || (_dbServer.State == MongoServerState.None))&lt;/p&gt;
                {
                    _dbServer.Connect();

                    MongoDatabase _db = _dbServer.GetDatabase(&quot;music&quot;);

                    MongoCollection&amp;lt;MongoDB.Bson.BsonDocument&amp;gt; _document = _db.GetCollection(&quot;tTrack&quot;);

                    IEnumerable&amp;lt;BsonValue&amp;gt; _trackIdList = _document.Distinct(&quot;TrackID&quot;);
                }
&lt;p&gt;            }&lt;br/&gt;
            catch (Exception ex)&lt;br/&gt;
            {&lt;br/&gt;
                System.Console.WriteLine(string.Format(&quot;Faile?Exception?&lt;/p&gt;
{0}
&lt;p&gt;&quot;, ex.Message));&lt;br/&gt;
            }&lt;br/&gt;
            finally&lt;/p&gt;
            {
                _dbServer.Disconnect();
            }
&lt;p&gt;        }&lt;br/&gt;
    }&lt;br/&gt;
}&lt;/p&gt;</description>
                <environment>OS:WIn7 x64 Enterprise&lt;br/&gt;
VS:VS2010</environment>
        <key id="14093">CSHARP-144</key>
            <summary>MongoCollection Can&apos;t distinct a large size of data</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="xuqing">xuqing</reporter>
                        <labels>
                    </labels>
                <created>Tue, 28 Dec 2010 04:35:52 +0000</created>
                <updated>Thu, 2 Apr 2015 18:27:54 +0000</updated>
                            <resolved>Tue, 28 Dec 2010 15:10:07 +0000</resolved>
                                    <version>0.9</version>
                                    <fixVersion>1.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="21864" author="rstam" created="Tue, 28 Dec 2010 15:10:07 +0000"  >&lt;p&gt;Works as designed.&lt;/p&gt;</comment>
                            <comment id="21863" author="rstam" created="Tue, 28 Dec 2010 15:09:39 +0000"  >&lt;p&gt;It&apos;s not a problem with the C# driver. It&apos;s a limitation on the amount of data that can be returned from the server in a single result document. You probably need to investigate other ways of doing this (map/reduce, client side, etc...).&lt;/p&gt;</comment>
                            <comment id="21851" author="xuqing" created="Tue, 28 Dec 2010 05:19:33 +0000"  >&lt;p&gt;In my document,Some Key don&apos;t only have english vales,Some values are saved as Chinese or Japanese.So maybe it&apos;s too large.But 821463 is a small part of the whole data.Now we hand this problem with linq.But maybe it&apos;s a issue of C# driver.Can this be fixed in the next version?&lt;/p&gt;</comment>
                            <comment id="21850" author="rstam" created="Tue, 28 Dec 2010 05:14:08 +0000"  >&lt;p&gt;I haven&apos;t tried to reproduce this yet, but I think you are just running into the limits of a BSON document. The result of a distinct command has to fit in a single BSON document. The error message makes it look like the result document is 25MB long, which is longer than a BSON document can be. If you divide 25354392 by 821463 you get 30.86, so given some overhead of how information is encoded it looks like you just can&apos;t return 821463 TrackIDs in a single result document.&lt;/p&gt;</comment>
                            <comment id="21849" author="xuqing" created="Tue, 28 Dec 2010 04:53:08 +0000"  >&lt;p&gt;the data in document like follow:&lt;/p&gt;

&lt;p&gt;{&lt;br/&gt;
  &quot;_id&quot;: &quot;4d16d843475bdea6f9fe0e12&quot;,&lt;br/&gt;
  &quot;TrackID&quot;: &quot;jwadypbo8rhuqcboge&quot;,&lt;br/&gt;
  &quot;TrackName&quot;: &quot;NiJigen Gangsta&quot;,&lt;br/&gt;
  &quot;Genre&quot;: &quot;Other&quot;,&lt;br/&gt;
  &quot;Duration&quot;: &quot;0:02:36&quot;,&lt;br/&gt;
  &quot;ReleaseDate&quot;: &quot;2004-12-31T16:00:00.0000000Z&quot;,&lt;br/&gt;
  &quot;LyricUrl&quot;: &quot;\n    &quot;,&lt;br/&gt;
  &quot;Language&quot;: &quot;&quot;,&lt;br/&gt;
  &quot;AlbumID&quot;: &quot;goad1qjz&quot;,&lt;br/&gt;
  &quot;AlbumName&quot;: &quot;Nijigen Gangsta E.P&quot;,&lt;br/&gt;
  &quot;ArtistIDList&quot;: &quot;ge3ucpj3&quot;,&lt;br/&gt;
  &quot;ArtistNameList&quot;: &quot;Amnjk&quot;,&lt;br/&gt;
  &quot;TopicID&quot;: &quot;&quot;&lt;br/&gt;
}&lt;/p&gt;</comment>
                            <comment id="21848" author="rstam" created="Tue, 28 Dec 2010 04:50:38 +0000"  >&lt;p&gt;What element names do the documents in the tTrack collection have? I&apos;ll need to create some fake data to try to reproduce this with, and I&apos;d like my fake data to be similar to yours.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrh9fr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14328</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>