Uh, interesting. The MongoDB Java driver's `Mongo...
# opensavvy
c
Uh, interesting. The MongoDB Java driver's
MongoCollection.countDocuments()
does not call db.countDocuments(), but executes
Copy code
aggregate([
    {
        "$match": {}
    },
    {
        "$group": {
            "_id": 1,
            "n": {
                "$sum": 1
            }
        }
    }
])
a
Why could this be the case? is there a scenario that this is more efficient?
c
No idea.
I'm thinking maybe the Java implementation is older than the db method? But that sounds strange, I think it's older than aggregation pipelines.
a
I doubt that the Java implementation came before aggregations
c
The empty
$match
is weird to me. It shouldn't be that hard to remove it? It's 69 pointless bytes.