I'm currently running db.stats
on a database and then I get back some information that includes dataSize
and storageSize
.
Now I'd imagine that
dataSize
is how much data is in the database storageSize
is how much data I could store before the database is full. BUT when I do a calculation like (dataSize/totalSize) * 100
to find the percentage of space that's used in the db, I get a number that's almost always greater than 100%.
How can I use db.stats
to tell me how much of the database space I'm currently using?
I'm using Mongo 3.6 atm.
Briefly:
dataSize
: The total size of the uncompressed data held in this database.storageSize
: The total amount of space allocated to collections in this database for document storage. This is the size (in bytes) of all the data extents in the database and it includes allocated-but-unused space in the data extents and space vacated by deleted documents within the data extents.More details in the docs.
However, neither of these metrics tell you anything about the maximum available space for a MongoDB database because storage footprint in MongoDB is not capped per database. Instead, you might want to think about how much diskspace you have made available to your MongoDB instance and then assess how much of that is in use by your database. Mongo v3.6 added two new dbstats metrics which are useful here:
dbStats.fsUsedSize
Total size of all disk space in use on the filesystem where MongoDB stores data.
dbStats.fsTotalSize
Total size of all disk capacity on the filesystem where MongoDB stores data.
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