Why does MongoDB takes up so much space?

后端 未结 1 521
感情败类
感情败类 2020-12-09 18:10

I am trying to store records with a set of doubles and ints (around 15-20) in mongoDB. The records mostly (99.99%) have the same structure.

When I store the data in

相关标签:
1条回答
  • 2020-12-09 18:41

    Basically, this is mongo preparing for the insertion of data. Mongo performs prealocation of storage for data to prevent (or minimize) fragmentation on the disk. This prealocation is observed in the form of a file that the mongod instance creates.

    First it creates a 64MB file, next 128MB, next 512MB, and on and on until it reaches files of 2GB (the maximum size of prealocated data files).

    There are some more things that mongo does that might be suspect to using more disk space, things like journaling...

    For much, much more info on how mongoDB uses storage space, you can take a look at this page and in specific the section titled Why are the files in my data directory larger than the data in my database?

    There are some things that you can do to minimize the space that is used, but these tequniques (such as using the --smallfiles option) are usually only recommended for development and testing use - never for production.

    0 讨论(0)
提交回复
热议问题