为什么 MongoDB 数据文件非常大?

    MongoDB aggressively preallocates data files to reserve space and avoid file system fragmentation. You can use the smallfiles flag to modify the file preallocation strategy.

     

    smallfiles
    默认值: false

    Set to true to modify MongoDB to use a smaller default data file size. Specifically, smallfiles reduces the initial size for data files and limits them to 512 megabytes. The smallfiles setting also reduces the size of each journal files from 1 gigabyte to 128 megabytes.

    Use the smallfiles setting if you have a large number of databases that each hold a small quantity of data. The smallfiles setting can lead mongod to create many files, which may affect performance for larger databases.

    如果采用smallfiles参数。则会是每个文件最大的大小限定为512M而不是默认的2G

    这样的缺点是。在大数量时会生成过多的文件。

    好处:个人理解小文件在读取时会相对快些。