Is it possible to find the largest document size in MongoDB?
db.collection.stats() shows average size, which is not really representative because in my
db.collection.stats()
You can use a small shell script to get this value.
Note: this will perform a full table scan, which will be slow on large collections.
let max = 0, id = null; db.test.find().forEach(doc => { const size = Object.bsonsize(doc); if(size > max) { max = size; id = doc._id; } }); print(id, max);