How come that the storage size of the whole mongo database is smaller than total document size?
Storage size
Collection size
This is probably because MongoDB preallocates data and journal files. In the data directory, MongoDB preallocates data files to a particular size, in part to prevent file system fragmentation. MongoDB names the first data file <databasename>. 0 , the next <databasename>.
In general, we recommend limiting collections to 10,000 per replica set. When users begin exceeding 10,000 collections, they typically see decreases in performance. To avoid this anti-pattern, examine your database and remove unnecessary collections.
Unless you create a capped collection, there is no limit to the number of documents in a collection. There is a 16MB limit to the size of a document (use gridfs in this situation) and limits in the storage engine for the size of the database and data.
MongoDB's WiredTiger storage engine compresses data and indexes by default, so the database storage size on disk (which includes both collection & index data) is typically smaller than the sum of the uncompressed document sizes and index sizes reported in collection stats.
The ratio of storage to uncompressed data size will vary depending on factors such as how compressible your data is, the number and type of indexes you create, whether you have deleted a significant number of documents (creating free space which is available for reuse), and any configuration changes from the default server or collection options.
In your example, you have a total of about 273.5 MB of data & indexes in this database using 70.9 MB of disk storage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With