What is meant by file and data size in MongoDB?

I started using MongoDB a few days ago and I have a problem understanding the database architecture. If I execute the request db.stats (); I had files, data, storage and indexing. While I am surfing, I discovered the following:

Storagesize = datasize + free space allocated for the collection

datasize = database size used by MongoDB

Here I could not understand file representation and data representation. For dataatize -> indexsize is also included ?. Please provide an exact solution for the specified attributes and please correct me if I mentioned any wrong.

Thanks,

+6
source share
3 answers
  • dataSize: sum of all actual data (BSON objects) used by the database, in bytes
  • indexSize: sum of all indexes used by the database, in bytes
  • storageSize: dataSize plus all pre-allocated spaces for the collection, in bytes
  • fileSize: the sum of the sizes of all files allocated for this database (e.g. test.0 + test.1, etc.), in bytes
  • nsSizeMB: The namespace file size for this database in megabytes.
  • avgObjSize: The average size of document objects in the database. This value includes addition and, therefore, cannot change when reducing the size of documents.
+16
source

I understand that this is an older question, but I decided that I would refer to the official db.stats() for anyone looking for similar information (like me).

Database Statistics Reference :: Fields

+1
source

As explained in this post about the different MongoDB performance metrics that you should track (using MMAPv1), all dbStats storage size metrics you should track are listed:

  • dataSize measures the space occupied by all documents and the addition in the database. Due to filling, dataSize reduced if documents are deleted, but not when they are reduced or become larger after updating - these operations simply add or borrow from filling documents.
  • indexSize returns the size of all indexes created in the database.
  • storageSize measures the size of all data extents in the database. With MMAPv1 , it is always greater than or equal to dataSize , since extents contain free space that is not yet in use or freed by deleted and moved documents. storageSize does not affect the compression or movement of documents.
  • fileSize matches the size of your data files. Obviously, it is always larger than storageSize , and it can be considered as the storage area of ​​your database on disk. It decreases only when the database is deleted and is not affected when deleting collections, documents or indexes.

Below is a chart with various important storage metrics returned by dbStats: dbStats storage metrics for MongoDB NOTE. With the MMAPv1 storage engine, MongoDB pre-allocates additional disk space for documents, so effective in-place updates are possible, as there is room for documents to grow without moving. This extra space is called padding.

+1
source

Source: https://habr.com/ru/post/903451/


All Articles