Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-254

Counting documents - 32 bits enough?

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.2
    • Affects Version/s: 1.1
    • Component/s: None
    • Minor Change

      I noticed that MongoCollection.Count(...) returns an Int32, while I do not recall MongoDB having a limit of 2^31 documents per collection (this might be the case, I wasn't trying to remember for too long).
      I wonder if such aggregation methods should return an Int64 to prevent loss (or even misinterpretation) of information on very large collections. While I agree that most of users should not occur this problem, it still looks like worth looking at.
      I took some time and checked Java driver (IIRC the only other one strongly-typed with collection abstraction), it uses "long" type (http://api.mongodb.org/java/current/com/mongodb/DBCollection.html#count() ), which (my Java knowledge is outdated by like 5 years or so, but google comes to help: http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html) is 64-bit.

      I understand that changing return type of something like Count() might break existing code (an explicit conversion is required), so this might be not so easy. If the need for 64-bit result is considered by you, but you don't like the idea of breaking existing code, introducing Count64() (concrete name isn't that important) counterparts to the existing aggregation methods might be the best way to go in the short term, eventually deprecating old 32-bit results and replacing them with Count32(), moving Count64() to Count().

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            onyxmaster Aristarkh Zagorodnikov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: